#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  int d;
  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 << "8" << endl;
  else
    cout << "5" << endl;
}
