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