#include <bits/stdc++.h>
using namespace std;
int fx[] = {1, 1, -1, -1, 2, 2, -2, -2};
int fy[] = {2, -2, 2, -2, 1, -1, 1, -1};
int cell[100][100];
int row, col;
int main() {
  int i, j, n, c;
  string s1;
  cin >> s1;
  if ((s1[0] == 'a' && s1[1] == '1') || (s1[0] == 'h' && s1[1] == '8') ||
      (s1[0] == 'h' && s1[1] == '1') || (s1[0] == 'a' && s1[1] == '8'))
    cout << "3" << endl;
  else if (s1[1] == '1' &&
           (s1[0] == 'a' || s1[0] == 'b' || s1[0] == 'c' || s1[0] == 'd' ||
            s1[0] == 'e' || s1[0] == 'f' || s1[0] == 'g' || s1[0] == 'h'))
    cout << "5" << endl;
  else if (s1[0] == 'a' &&
           (s1[1] == '1' || s1[1] == '2' || s1[1] == '3' || s1[1] == '4' ||
            s1[1] == '5' || s1[1] == '6' || s1[1] == '7' || s1[1] == '7'))
    cout << "5" << endl;
  else if (s1[1] == '8' &&
           (s1[0] == 'a' || s1[0] == 'b' || s1[0] == 'c' || s1[0] == 'd' ||
            s1[0] == 'e' || s1[0] == 'f' || s1[0] == 'g' || s1[0] == 'h'))
    cout << "5" << endl;
  else if (s1[0] == 'h' &&
           (s1[1] == '1' || s1[1] == '2' || s1[1] == '3' || s1[1] == '4' ||
            s1[1] == '5' || s1[1] == '6' || s1[1] == '7' || s1[1] == '8'))
    cout << "5" << endl;
  else
    cout << "8" << endl;
  return 0;
}
