#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string s;
  cin >> s;
  int r = s[0] - 'a' + 1;
  int c = s[1] - '0';
  if (r < 8 and r > 1 and c < 8 and c > 1) {
    cout << 8 << '\n';
  } else if ((r == 1 and c == 1) or (r == 8 and c == 8) or
             (r == 1 and c == 8) or (r == 8 and c == 1)) {
    cout << 3 << '\n';
  } else {
    cout << 5 << '\n';
  }
  return 0;
}
