
import java.io.*;
import java.util.Arrays;
/**
 *  Description of the Class
 *
 *@author     jeff
 *@created    May 15, 2003
 */
public class Anagrams {
	/**
	 *  The main program for the Anagrams class
	 *
	 *@param  args             The command line arguments
	 *@exception  IOException  Description of the Exception
	 */
	public static void main(String[] args) throws IOException {

		boolean matches;
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		if (args.length == 2) {
			 {
				String word1 = args[0];
				String word2 = args[1];

				String lower1 = word1.toLowerCase();
				String lower2 = word2.toLowerCase();
				int[] asciiWordOne = new int[26];
				int[] asciiWordTwo = new int[26];
				asciiWordOne = wordToArray(lower1);
				asciiWordTwo = wordToArray(lower2);
				System.out.println(lower1 + " " + lower2);
				matches = equals(asciiWordOne, asciiWordTwo);
				if (matches) {
					System.out.println("Yes, " + word1 + " and " + word2 + " are anagrams.");
				} else {
					System.out.println("No, " + word1 + " and " + word2 + " are not anagrams.");
				}
			}
		} else {
			System.out.println("You entered the wrong number of arguments");
		}
	}


	/**
	 *  Description of the Method
	 *
	 *@param  word  Description of the Parameter
	 *@return       Description of the Return Value
	 */
	public static int[] wordToArray(String word) {
		int[] alphabet = new int[26];
		char letter;
		int letterValue;
		int index;
		for (int j = 0; j < word.length(); j++) {
			letter = word.charAt(j);
			letterValue = (int) letter;
			index = (letterValue - 'a');
			alphabet[index] = (alphabet[index] + 1);
		}
		return alphabet;
	}


	/**
	 *  Description of the Method
	 *
	 *@param  array1  Description of the Parameter
	 *@param  array2  Description of the Parameter
	 *@return         Description of the Return Value
	 */
	public static boolean equals(int[] array1, int[] array2) {
		boolean matches = true;
		 {
			for (int u = 0; u < 25; u++) {
				if (array1[u] != array2[u]) {
					matches = false;
				}
			}

		}
		return matches;
	}

}
