#include <bits/stdc++.h>
int main() {
  char c;
  int col, row, aled = 0;
  scanf("%c%i", &c, &row);
  col = c - 96;
  if (row == 1 || row == 8) {
    if (col == 1 || col == 8) {
      printf("3\n");
    } else {
      printf("5\n");
    }
  } else if (col == 1 || col == 8) {
    if (row == 1 || row == 8) {
      printf("3\n");
    } else {
      printf("5\n");
    }
  } else {
    printf("8\n");
  }
  return 0;
}
