#include <bits/stdc++.h>
using namespace std;
int main() {
  char c, d;
  cin >> c >> d;
  cout << (((c == 'a' || c == 'h') ? 2 : 3) *
           ((d == '1' || d == '8') ? 2 : 3)) -
              1
       << endl;
  return 0;
}
