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