#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1000001];
  cin >> s;
  if (s[0] == 'a' and s[1] == '1' or s[0] == 'a' and s[1] == '8' or
      s[0] == 'h' and s[1] == '1' or s[0] == 'h' and s[1] == '8') {
    cout << "3";
  } else if (s[0] == 'a' or s[0] == 'h' or s[1] == '1' or s[1] == '8') {
    cout << "5";
  } else
    cout << "8";
  return 0;
}
