#include <bits/stdc++.h>
using namespace std;
map<char , int>q;
typedef long long LL;
int num;
string a , b;
int main()
{
cin.tie(0);
cout.tie(0);
q['A'] = 1;
num = q['A'];
for(char i = 'A' ; i <= 'Z' ;)
q[++ i] = ++ num;
getline(cin , a);
getline(cin , b);
LL res1 = 1 , res2 = 1;
for(int i = 0 ; i < a.size() ; i ++ )
res1 *= q[a[i]];
for(int i = 0 ; i < b.size() ; i ++ )
res2 *= q[b[i]];
res1 %= 47 , res2 %= 47;
if(res1 == res2) cout << "GO";
else cout << "STAY";
return 0;
}