#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  if (x == "a8" || x == "a1" || x == "h8" || x == "h1")
    cout << 3 << endl;
  else if (x[0] == 'h' || x[0] == 'a' || x[1] == '8' || x[1] == '1')
    cout << 5 << endl;
  else
    cout << 8 << endl;
  return 0;
}
