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