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