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