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