The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and d is the row from '1' to '8'. Find the number of moves permitted for the king.

Check the king's moves here https://en.wikipedia.org/wiki/King_(chess).

<image> King moves from the position e4

Input

The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.

Output

Print the only integer x — the number of moves permitted for the king.

Example

Input

e4


Output

8

import java.io.*;
import java.util.*;

public class pp1 {
    FastScanner in;
    PrintWriter out;
    class Graph{
        int V;
        ArrayList<Integer> adjlist[];
        Graph(int n){
            this.V = n;
            this.adjlist = new ArrayList[n];
            for(int i=0;i<this.V;i++){
                adjlist[i] = new ArrayList<>();
            }
        }
        void addEdge(int u, int v){
            adjlist[u].add(v);
            adjlist[v].add(u);
        }
        int dfs(int start, int dest, boolean[] vis, List<Integer> happy){
            vis[start]=true;
            int sum=0;
            boolean flag=false;
            for(int i=0;i<adjlist[start].size();i++){
                int b = adjlist[start].get(i);
                if(!vis[b]){
                    flag=true;
                    sum+=dfs(b, dest+1,vis, happy );
                }
            }
            int remain = dest-sum;
            happy.add(remain);
            return sum+1;
        }



    }

    List<Integer> []al;
    boolean [] visited;
    int [] parent;

    void bfs(int src,int dest,List<Integer> [] list){
        Queue<Integer> queue=new LinkedList<>();
        queue.add(src);
        parent[src]=-1;
        visited[src]=true;
        while(!queue.isEmpty()){
            int u=queue.poll();

            for(int v : al[u]){
                if(!visited[v]){
                    queue.add(v);
                    parent[v]=u;
                    visited[v]=true;
                    if(v==dest){
                        break;
                    }
                }
            }
        }
        List<Integer> edge=new ArrayList<>();
        edge.add(dest);
        int k=dest;
        while(parent[k]!=src && parent[k]!=-1){
            k=parent[k];
            edge.add(k);
        }
        edge.add(src);
        for(int i=1;i<edge.size();i++){

            int a=edge.get(i-1);
            int b=edge.get(i);
            list[a].add(b);
        }


    }

    void solve() {
        //This is the main logic code
        String z=in.next();
        char c=z.charAt(0);
        char r=z.charAt(1);
        int m=0;
        if((c=='a' && r=='1') || (c=='h' && r=='1') || (c=='h' && r=='8') || (c=='a' && r=='8'))
        {m=3;}
        else if((c!='a' && r=='1') || (c!='h' && r=='1') || (c!='h' && r=='8') || (c!='a' && r=='8') || (c=='a' && r!='1') || (c=='h' && r!='1') || (c=='h' && r!='8') || (c=='a' && r!='8'))
        { m=5;}
        else
        {  m=8;}
        out.println(m);

    }

    public static void main(String[] args) {
        new pp1().runIO();
    }

    void run() {
        try {
            in = new FastScanner(new File("A.in"));
            out = new PrintWriter(new File("A.out"));
            solve();
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}