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