#include <bits/stdc++.h>
using namespace std;
int main() {
  char c, d;
  scanf("%c%c", &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");
  return 0;
}
