#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, i;
  char c, j;
  cin >> c >> d;
  if (d == 1 || d == 8) {
    if (c == 'a' || c == 'h') {
      cout << 3;
    } else
      cout << 5;
  }
  if (d != 1 && d != 8) {
    if (c == 'a' || c == 'h') {
      cout << 5;
    }
  }
  if (d != 1 && d != 8) {
    if (c != 'a' && c != 'h') {
      cout << 8;
    }
  }
}
