include <bits/stdc++.h>
define int long long
define iostream() ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
using namespace std;
const int maxn = 1e6+7;
const int MAXN = maxn / 2;
bool a = true,b = false,c = false;
signed main()
{
iostream();
string s;
cin >> s;
for (int i = 0; i < s.length(); i++)
{
switch (s[i])
{
case 'A':
a = !a;
b = !b;
break;
case 'B':
b = !b;
c = !c;
break;
case 'C':
a = !a;
c = !c;
}
}
if (a) cout << 1;
else if (b) cout << 2;
else cout << 3;
return 0;
}