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