import java.util.*;
public class anagrams {
public static void main(String[] args) {
int count=0,i;
Scanner sc= new Scanner(System.in);
System.out.println("enter first string");
String a=sc.nextLine();
System.out.println("enter second string");
String b=sc.nextLine();
a=a.toLowerCase();
b=b.toLowerCase();
char a1[]=a.toCharArray();
char a2[]=b.toCharArray();
Arrays.sort(a1);
Arrays.sort(a2);
if(a1.length!=a2.length)
count++;
if(count==0)
for(i=0;i<a1.length;i++)
if(a1[i]!=a2[i])
count++;
if(count==0)
System.out.println("anagrams");
else
System.out.println("not anagrams");
}
}