#include <bits/stdc++.h>
using namespace std;
int main()
{
int res = 0, year;
for(int i = 0; i < 5; i++)
{
cin >> year;
if(year / 1000 == year % 100 / 10 && year % 1000 / 100 + 1 == year % 10)
res ++;
}
cout << res << endl;
return 0;
}