#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e9 + 1;
int main() {
  char a, b;
  cin >> a >> b;
  if ((a == 'a' || a == 'h') && (b == '1' || b == '8')) {
    cout << 3;
    return 0;
  }
  if ((a == 'a' || a == 'h') || (b == '1' || b == '8')) {
    cout << 5;
    return 0;
  }
  cout << 8;
  return 0;
}
