x=input()
y=input()
if(len(x)==len(y)):
    if(sorted(x)==sorted(y)):
        print("anagram")
    else:
        print("Not anagram")
else:
    print("not anagram")