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