#include <iostream>
#include <string>
using namespace std;
int f(string s) {
int res = 1;
for (char c: s) {
res *= c - 'A' + 1;
res %= 47;
}
return res;
}
int main() {
string a, b;
cin >> a >> b;
if (f(a) == f(b)) {
cout << "GO" << endl;
} else {
cout << "STAY" << endl;
}
return 0;
}