#include <bits/stdc++.h>
using namespace std;
char letter[27] = {1,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
int main()
{
string comet,team;
int cometscore = 0,teamscore = 0;
cin >> comet;
cin >> team;
for (int i = 0; i < comet.length(); i++)
{
for (int j = 1; j <= 26; j++)
{
if (comet[i] == letter[j]) cometscore *= j;
break;
}
}
for (int i = 0; i < team.length(); i++)
{
for (int j = 1; j <= 26; j++)
{
if (team[i] == letter[j]) teamscore *= j;
break;
}
}
if (cometscore == teamscore) cout << "GO" << endl;
else cout << "STAY" << endl;
return 0;
}