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