#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int a;
  char ch;
  scanf("%c%d", &ch, &a);
  int b = ch - 'a' + 1;
  if (a > 1 && a < 8 && b > 1 && b < 8)
    cout << "8" << endl;
  else if (a == 1 && (b == 1 || b == 8) || a == 8 && (b == 1 || b == 8))
    cout << "3" << endl;
  else
    cout << "5" << endl;
  return 0;
}
