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