#include #include #include #include #include #include #include #include using namespace std; pair stringToCoordinates(string s) { int coord1 = s[0] - 'a'; int coord2 = s[1] - '0'; if (s.length() == 3) coord2 = 10*coord2 + s[2] - '0'; coord2--; return make_pair(coord1, coord2); } bool areOnLine(pair p1, pair p2) { if (p1.first == p2.first) return true; if (p1.second == p2.second) return true; if (p1.first-p1.second == p2.first-p2.second) return true; return false; } int main (void) { string s1, s2; cin >> s1 >> s2; pair p1 = stringToCoordinates(s1); pair p2 = stringToCoordinates(s2); int sol = 0; // Go through board for (int i = 0; i < 11; i++) { int minj = max(0, i-5); int maxj = min(10, 5+i); for (int j = minj; j <= maxj; j++) { pair p3 = make_pair(i,j); if ( (p3 != p1) && (p3 != p2) ) if ( (areOnLine(p1,p3)) and (areOnLine(p2,p3)) ) sol++; } } cout << sol << "\n"; return 0; }