#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
set<char> collection;
while(cin >> s){
collection.clear();
for(auto ch:s)
collection.insert(ch);
if(collection.size() > 2)
cout<<0<<endl;
else if(collection.size() == 1)
cout<<1<<endl;
else
cout<<2<<endl;
}
return 0;
}