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