#include<bits/stdc++.h>
//#include<AC自动机>
using namespace std;
#define ll long long
#define db double
int main(){
ios::sync_with_stdio(false),cin.tie(NULL);
char x;
int y;
cin>>x>>y;
if(x=='a'&&y>1&&y<8) cout<<5;
if(x=='a'&&y==1) cout<<3;
if(x=='a'&&y==8) cout<<3;
if(x=='h'&&y==1) cout<<3;
if(x=='h'&&y==8) cout<<3;
if(x=='h'&&y>1&&y<8) cout<<5;
if(x!='a'&&x!='h'&&y>1&&y<8) cout<<8;
return 0;
}