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