#include <bits/stdc++.h>
using namespace std;
int main() {
  int c;
  char d;
  int x[8] = {1, 2, 3, 4, 5, 6, 7, 8};
  cin >> d >> c;
  if (c <= 8 && d <= 'h') {
    if (d == 'a' || d == 'h') {
      if (c == 1 || c == 8)
        cout << x[2] << endl;
      else
        cout << x[4] << endl;
    } else if (c == 8 || c == 1)
      cout << x[4] << endl;
    else
      cout << x[7] << endl;
  }
  return 0;
}
