lst = input().split()
dicts = {}
max = 0
for i in lst:
if i in dicts:
dicts[i] += 1
else:
dicts[i] = 1
if dicts[i] > max:
max = dicts[i]
if max == 3:
print(0)
elif max == 2:
print(1)
else:
max = 0
for i in range(2):
for j in range(i + 1, 3):
if lst[i][1] == lst[j][1] and abs(ord(lst[i][0]) - ord(lst[j][0])) < 3:
max += 1
if max == 0:
print(2)
elif max > 0 and max < 3:
print(1)
else:
print(0)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<ll, ii> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
#define fi first
#define se second
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int N = 1e4;
int f[127][10];
void solve() {
string a, b, c;
cin >> a >> b >> c;
f[a[1]][a[0]-'0']++;
f[b[1]][b[0]-'0']++;
f[c[1]][c[0]-'0']++;
int mx = 0;
int p[3] = {'m', 'p', 's'};
for(int i = 0; i < 3; i++) {
for(int j = 1; j <= 9; j++) {
mx = max(mx, f[p[i]][j]);
}
}
for(int i = 0; i < 3; i++) {
for(int j = 3; j <= 9; j++) {
mx = max(mx, (f[p[i]][j]!= 0)+(f[p[i]][j-1] != 0)+(f[p[i]][j-2] != 0));
}
}
cout << 3 - mx << "\n";
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int T = 1;
//cin >> T;
for(int i = 1; i <= T; i++) {
//cout << "Case #" << i << ":\n";
solve();
}
return 0;
}
237A - Free Cash | 1615B - And It's Non-Zero |
1619E - MEX and Increments | 34B - Sale |
1436A - Reorder | 1363C - Game On Leaves |
1373C - Pluses and Minuses | 1173B - Nauuo and Chess |
318B - Strings of Power | 1625A - Ancient Civilization |
864A - Fair Game | 1663B - Mike's Sequence |
448A - Rewards | 1622A - Construct a Rectangle |
1620A - Equal or Not Equal | 1517A - Sum of 2050 |
620A - Professor GukiZ's Robot | 1342A - Road To Zero |
1520A - Do Not Be Distracted | 352A - Jeff and Digits |
1327A - Sum of Odd Integers | 1276A - As Simple as One and Two |
812C - Sagheer and Nubian Market | 272A - Dima and Friends |
1352C - K-th Not Divisible by n | 545C - Woodcutters |
1528B - Kavi on Pairing Duty | 339B - Xenia and Ringroad |
189A - Cut Ribbon | 1182A - Filling Shapes |