public class IsomorphicWords {
  
  public int countPairs(String[] words) {
    int total = 0;
    for(int i = 0; i < words.length; i++){
      for(int j = i + 1; j < words.length; j++){
        boolean check = isIso(words[i], words[j]);
        if(check){
          total++;
        }
      }
    }
    return total;
  }
  
  public boolean isIso(String wordOne, String wordTwo){
    int[] wOne = encode(wordOne);
    int[] wTwo = encode(wordTwo);
    
    for(int i = 0; i < wOne.length; i++){
      if(wOne[i] != wTwo[i]){
        return false;
      }
    }
    return true;
  }
  
  public int[] encode(String word){
    int[] answer = new int[word.length()];
    for(int i = 0; i < word.length(); i++) {
      answer[i] = word.indexOf(word.charAt(i));
    }
    return answer;
  }
  

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    IsomorphicWords in = new IsomorphicWords();
    String[] strings = {"abca", "zbxz"};
    System.out.print(in.countPairs(strings));
  }

}
