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