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