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