#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAXN = 1;
int a;
char c;
int main(int argc, char const *argv[]) {
  scanf("%c%d", &c, &a);
  if (c == 'a' || c == 'h') {
    if (a == 1 || a == 8)
      printf("3\n");
    else
      printf("5\n");
    return 0;
  }
  if (a == 1 || a == 8) {
    if (c == 'a' || c == 'h')
      printf("3\n");
    else
      printf("5\n");
    return 0;
  }
  printf("8\n");
  return 0;
}
