#include <bits/stdc++.h>
using namespace std;
int main() {
  string position;
  cin >> position;
  char row = position.at(0);
  int col = position.at(1) - '0';
  if (row < 'h' && row > 'a' && col > 1 && col < 8) {
    cout << 8;
  } else if (row < 'h' && row > 'a' && (col == 1 || col == 8)) {
    cout << 5;
  } else if ((row == 'h' || row == 'a') && (col == 1 || col == 8)) {
    cout << 3;
  } else if ((row == 'h' || row == 'a') && (col > 1 || col < 8)) {
    cout << 5;
  }
  return 0;
}
