#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[2];
  for (int i = 0; i < 2; i++) {
    cin >> s[i];
  }
  if (s[0] != 'a' && s[1] != '1' && s[0] != 'h' && s[1] != '8') {
    cout << "8" << endl;
  } else {
    if ((s[0] == 'a' && (s[1] == '1' || s[1] == '8')) ||
        s[0] == 'h' && (s[1] == '1' || s[1] == '8')) {
      cout << "3" << endl;
    } else {
      cout << "5" << endl;
    }
  }
}
