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