https://codeforces.com/contest/1191/problem/B
按字母相等的个数分类
然后考虑数字差值 0 1 2
#include<bits/stdc++.h>
#include<deque>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const ll MOD=998244353;
const int maxn=2e5+5;
int q,k,ans;
int main()
{
vector<string> s(3);
cin>>s[0]>>s[1]>>s[2];
sort(s.begin(),s.end()); //按数字递增
string a=s[0],b=s[1],c=s[2];
if(a[1]==b[1] && b[1]==c[1]){ //3个字母相同前提下
if(a[0]==b[0] && b[0]==c[0]) //数字也都相同
cout<<0<<endl;
else if(a[0]==b[0] || b[0]==c[0])//二个数字相等
cout<<1<<endl;
else if(a[0]+1==b[0] && b[0]+1==c[0]) //递增
cout<<0<<endl;
else if(a[0]+1==b[0] || b[0]+1==c[0] || a[0]+2==b[0] || b[0]+2==c[0])
cout<<1<<endl;
else
cout<<2<<endl;
}
else if(a[1]==b[1]){
if(a[0]==b[0] || a[0]+1==b[0] || a[0]+2==b[0])
cout<<1<<endl;
else
cout<<2<<endl;
}
else if(b[1]==c[1]){
if(b[0]==c[0] || b[0]+1==c[0] || b[0]+2==c[0])
cout<<1<<endl;
else
cout<<2<<endl;
}
else if(a[1]==c[1]){
if(a[0]==c[0] || a[0]+1==c[0] || a[0]+2==c[0])
cout<<1<<endl;
else
cout<<2<<endl;
}
else{ //各一种
cout<<2<<endl;
}
return 0;
}
/*
*/