#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int readInt() {
  bool minus = false;
  int result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus)
    return -result;
  else
    return result;
}
int main() {
  string s;
  cin >> s;
  int n = s[1] - 48;
  if (s[0] == 'a' || s[0] == 'h') {
    if (n == 1 || n == 8)
      cout << "3" << endl;
    else
      cout << "5" << endl;
  } else {
    if (n == 1 || n == 8)
      cout << "5" << endl;
    else
      cout << "8" << endl;
  }
  return 0;
}
