#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[8][8];
  char s;
  int n;
  a[0][0] = a[7][7] = a[0][7] = a[7][0] = 3;
  a[0][1] = a[0][2] = a[0][3] = a[0][4] = a[0][5] = a[0][6] = 5;
  a[1][0] = a[2][0] = a[3][0] = a[4][0] = a[5][0] = a[6][0] = 5;
  a[7][1] = a[7][2] = a[7][3] = a[7][4] = a[7][5] = a[7][6] = 5;
  a[1][7] = a[2][7] = a[3][7] = a[4][7] = a[5][7] = a[6][7] = 5;
  for (int i = 1; i < 7; ++i)
    for (int j = 1; j < 7; ++j) {
      a[i][j] = 8;
    }
  cin >> s >> n;
  cout << a[s - 'a'][n - 1];
}
