#include <bits/stdc++.h>
using namespace std;
int main() {
  int d;
  char c;
  cin >> c >> d;
  if ((c == 'h' && d == 1) || (c == 'a' && d == 1) || (c == 'a' && d == 8) ||
      (c == 'h' && d == 8))
    cout << 3;
  else if ((c == 'a' && (d >= 2 && d <= 7)) ||
           (c == 'h' && (d >= 2 && d <= 7)) ||
           ((c != 'a' && c != 'h') && d == 1) ||
           ((c != 'a' && c != 'h') && d == 8))
    cout << 5;
  else
    cout << 8;
  return 0;
}
