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