#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    string str1,str2;
    getline(cin,str1);
    getline(cin,str2);
    
    if(str1.empty() || str2.empty()){
        cout<<"Invalid input";
        return 0;
    }
    for(char &c:str1){
        if(!isalpha(c)){
            cout<<"Invalid input";
            return 0;
        }
    }
    for(char &c:str2){
        if(!isalpha(c)){
            cout<<"Invalid input";
            return 0;
        }
    }
    for(char &c:str1)c = tolower(c);
    for(char &c:str2)c = tolower(c);
    if(str1.length()!= str2.length()){
        cout<<"Not Anagrams";
        return 0;
    }

        sort(str1.begin(),str1end());
        sort(str2.begin(),str2.end());
        if(str1==str2)
        cout<<"Anagrams";
        else
        cout<<"Not Anagrams";
        return 0;
    }
}