#include <bits/stdc++.h>
using namespace std;

int main() {
    int x, y;
    cin >> x >> y;  // nhap toa do cua quan Ma (cot x, dong y)
    // 8 huong di chuyen co the cua quan Ma
    int dx[] = {2, 2, -2, -2, 1, 1, -1, -1};
    int dy[] = {1, -1, 1, -1, 2, -2, 2, -2};
    int count = 0;  // bien dem so o co the di duoc
    for (int i = 0; i < 8; i++) {
        int nx = x + dx[i];  // toa do cot moi
        int ny = y + dy[i];  // toa do dong moi
        // kiem tra neu vi tri moi van nam trong ban co
        if (nx >= 1 && nx <= 8 && ny >= 1 && ny <= 8) {
            count++;  // tang bien dem
        }
    }
    cout << count << endl;  // in ra ket qua
    return 0;
}

