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