Problem: A new airplane SuperPuperJet has an infinite number of rows, numbered with positive integers starting with 1 from cockpit to tail. There are six seats in each row, denoted with letters from 'a' to 'f'. Seats 'a', 'b' and 'c' are located to the left of an aisle (if one looks in the direction of the cockpit), while seats 'd', 'e' and 'f' are located to the right. Seats 'a' and 'f' are located near the windows, while seats 'c' and 'd' are located near the aisle. 

<image>

It's lunch time and two flight attendants have just started to serve food. They move from the first rows to the tail, always maintaining a distance of two rows from each other because of the food trolley. Thus, at the beginning the first attendant serves row 1 while the second attendant serves row 3. When both rows are done they move one row forward: the first attendant serves row 2 while the second attendant serves row 4. Then they move three rows forward and the first attendant serves row 5 while the second attendant serves row 7. Then they move one row forward again and so on.

Flight attendants work with the same speed: it takes exactly 1 second to serve one passenger and 1 second to move one row forward. Each attendant first serves the passengers on the seats to the right of the aisle and then serves passengers on the seats to the left of the aisle (if one looks in the direction of the cockpit). Moreover, they always serve passengers in order from the window to the aisle. Thus, the first passenger to receive food in each row is located in seat 'f', and the last one — in seat 'c'. Assume that all seats are occupied.

Vasya has seat s in row n and wants to know how many seconds will pass before he gets his lunch.

Input

The only line of input contains a description of Vasya's seat in the format ns, where n (1 ≤ n ≤ 1018) is the index of the row and s is the seat in this row, denoted as letter from 'a' to 'f'. The index of the row and the seat are not separated by a space.

Output

Print one integer — the number of seconds Vasya has to wait until he gets his lunch.

Examples

Input

1f


Output

1


Input

2d


Output

10


Input

4a


Output

11


Input

5e


Output

18

Note

In the first sample, the first flight attendant serves Vasya first, so Vasya gets his lunch after 1 second.

In the second sample, the flight attendants will spend 6 seconds to serve everyone in the rows 1 and 3, then they will move one row forward in 1 second. As they first serve seats located to the right of the aisle in order from window to aisle, Vasya has to wait 3 more seconds. The total is 6 + 1 + 3 = 10.

Solution (in JAVA):

Solution:

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;


import java.util.*;

public class random_num {
public static int mod= (int) (Math.pow(10,9)+7);
	public static void main(String args[]){
		InputReader s= new InputReader(System.in);
		OutputStream outputStream= System.out;
		PrintWriter out= new PrintWriter(outputStream);
		String str=s.nextLine();
		String str1="";
		for(int i=0;i<str.length()-1;i++){
			str1+=str.charAt(i);
		}
		long n=Long.parseLong(str1);
		//System.out.println(n);
		long modi=n%4;
		long divi=n/4;
		if(modi==0){
			modi=2;
			divi-=1;
		}
		else if(modi==3)
			modi-=2;
		long ans=16*divi+7*(modi-1);
		if(str.charAt(str.length()-1)=='a') ans+=4;
		else if(str.charAt(str.length()-1)=='b') ans+=5;
		else if(str.charAt(str.length()-1)=='c') ans+=6;
		else if(str.charAt(str.length()-1)=='d') ans+=3; 
		else if(str.charAt(str.length()-1)=='e') ans+=2;
		else if(str.charAt(str.length()-1)=='f') ans++;
		System.out.println(ans);
		out.close();
		
	}
	static class InputReader {
		
	    public BufferedReader reader;
	    public StringTokenizer tokenizer;
 
	    public InputReader(InputStream inputstream) {
	      reader = new BufferedReader(new InputStreamReader(inputstream));
	      tokenizer = null;
	    }
	    
	    public String nextLine(){
	    	String fullLine=null;
	    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	              fullLine=reader.readLine();
	            } catch (IOException e) {
	              throw new RuntimeException(e);
	            }
	            return fullLine;
	          }
	          return fullLine;
	    }
		public String next() {
	      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	        try {
	          tokenizer = new StringTokenizer(reader.readLine());
	        } catch (IOException e) {
	          throw new RuntimeException(e);
	        }
	      }
	      return tokenizer.nextToken();
	    }
		public long nextLong() {
		      return Long.parseLong(next());
		    }
	    public int nextInt() {
	      return Integer.parseInt(next());
	    }
	  }
	
	public static HashMap<Integer,Long> getcatalan(int n){
		HashMap<Integer,Long> a=new HashMap<Integer,Long>();
		a.put(0,(long)1);
		for(int i=1;i<=n+1;i++){
			long m=2*(2*i-1);
			long m1=m*a.get(i-1);
			long m3=m1/(i+1);
			//out.println(m+" "+m1+" "+m2+" "+m3);
			
			a.put(i,m3%1000000007);
		}
		return a;
	}
	
	public static int getGdc(int[] x) {
	    // get the smallest of all number no need to check for higher values
	    int smallest = getSmallest(x);

	    for(int i = smallest; i >= 1; i--) {
	       int j;
	       for(j = 0; j < x.length; ++j) {
	           if(x[j] % i != 0)
	               break;
	       }
	       // if we pass through the array with all % == 0 return the value
	       if(j == x.length)
	           return i;
	    }
	    // so the only possible is 1
	    return 1;
	}

	// return smallest number of an array of int
	public static int getSmallest(int[] x) {
	    int smallest = x[0];
	    for(int i = 1; i < x.length; ++i) {
	        if(x[i] < smallest)
	            smallest = x[i];
	    }
	    return smallest;
	}
	public static long gcd(long number1, long number2) {  
		if(number2 == 0){
			return number1;
		} 
		return gcd(number2, number1%number2); 
	}
	
	public static int combinations(int n,int r){
		if(n==r) return 1;
		if(r==1) return n;
		if(r==0) return 1;
		return combinations(n-1,r)+ combinations(n-1,r-1);
	}
	public static long binomialCoeff(int n, int k)
	{
	    long C[][]= new long[n+1][k+1];
	    int i, j;
	 
	    // Caculate value of Binomial Coefficient in bottom up manner
	    for (i = 0; i <= n; i++)
	    {
	        for (j = 0; j <= Math.min(i, k); j++)
	        {
	            // Base Cases
	            if (j == 0 || j == i)
	                C[i][j] = 1;
	 
	            // Calculate value using previosly stored values
	            else
	                C[i][j] = C[i-1][j-1] + C[i-1][j];
	        }
	    }
	 
	    return C[n][k];
	}
	public static long expo(long a, long b){
	    if (b==1)
	        return a;
	    if (b==2)
	        return a*a;

	    if (b%2==0){
	            return expo(expo(a,b/2),2);
	    }
	    else{
	        return a*(expo(expo(a,(b-1)/2),2));
	    }
	}
	
	public static int[] sieve(int N){
		int arr[]= new int[N+1];
		int b[]=new int[N+1];
		for(int i=2;i<Math.sqrt(N);i++){
			if(arr[i]==0){
				
				for(int j= i*i;j<= N;j= j+i){
					arr[j]=1;
				}
			}
		}
		return arr;
		// All the i for which arr[i]==0 are prime numbers.
	}
	static class Pair implements Comparable<Pair>
    {
        int f,s;
        Pair(int ii, int cc)
        {
            f=ii;
            s=cc;
        }
        
        public int compareTo(Pair o) 
        {
            return Integer.compare(this.f, o.f);
        }
        
    }
	public static class company{
		public int t;
		public int d;
		public company(int m,int f){
			this.t=m;
			this.d=f;
		}
		public int get_t(){
			return this.t;
		}
		public int get_d(){
			return this.d;
		}
	}
	public static class pair_comparator implements Comparator<company>{

		@Override
		public int compare(company arg0, company arg1) {
			// TODO Auto-generated method stub
			return arg0.t-arg1.t;
		}
		
	}

}