#include <bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int cnt1 = 0, cnt2 = 0;
string s1, s2;
cin >> s1 >> s2;
for (int j = 0; j < s1.size(); j++) {
cnt1 += s1[j]-64;
}
for (int j = 0; j < s2.size(); j++) {
cnt2 += s2[j]-64;
}
if (cnt2 % 47 == cnt1 % 47) {
cout << "GO";
}
else {
cout << "STAY";
}
return 0;
}