#include <iostream>
#include <string>
#include <vector>
#include <cctype>
using namespace std;

bool isValid(const string &s) {
    if (s.empty()) return false;
    
    for (char c : s) {
        if (!isalpha(c)) {
            return false;
        }
    }
    
    return true;
}

int main() {
    string str1, str2;
    getline(cin, str1);
    getline(cin, str2);
    
    if (!isValid(str1) || !isValid(str2)) {
        cout << "Invalid input";
        return 0;
    }
    
    if (str1.length() != str2.length()) {
        cout << "Not Anagrams";
        return 0;
    }
    
    vector <int> freq(26, 0);
    
    for (char c : str1) freq[tolower(c) - 'a']++;
    for (char c : str2) freq[tolower(c) - 'a']-;
    
    for (int x : freq) {
        if (x != 0) {
            cout << "Not Anagrams";
            return 0;
        }
    }
    
    cout << "Anagrams";
    return 0;
}