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