// C++ implementation of above approach 
#include <bits/stdc++.h> 
using namespace std;
#define int long long 
  
// Function to return the count of 
// total positions the Bishop 
// can visit in a single move 
void countSquares(int row, int column) 
{ 
  
    // Count top left squares 
    int topLeft = min(row, column) - 1; 
  
    // Count bottom right squares 
    int bottomRight = 8 - max(row, column); 
  
    // Count top right squares 
    int topRight = min(row, 9 - column) - 1; 
  
    // Count bottom left squares 
    int bottomLeft = 8 - max(row, 9 - column); 
  
    // Return total count 
    cout<< (topLeft + topRight + bottomRight + bottomLeft); 
} 
  
// Driver code 
int_32t main() 
{ 
  
    // Bishop's Position 
    int row, column ;
cin>>row>>coloumn; 
countSquares(row,coloumn);
  
     
  
    return 0; 
} 