#include <bits/stdc++.h>
using namespace std;
long long x, y, z, a, b;
string s;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> s;
  a = 8;
  if (s[0] == 'h' || s[0] == 'a') {
    a -= 3;
  }
  if (s[1] == '1' || s[1] == '8') {
    a -= 3;
  }
  cout << max(a, 3 * 1LL) << endl;
  return 0;
}
