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