#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int c, r;
  c = str[0] - 96;
  r = str[1] - 48;
  if ((c == 1 && r == 1) || (c == 8 && r == 8) || (c == 1 && r == 8) ||
      (c == 8 && r == 1))
    cout << 3 << endl;
  else if ((c == 1) || (c == 8) || (r == 1) || (r == 8)) {
    cout << 5 << endl;
  } else {
    cout << 8 << endl;
  }
  return 0;
}
