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