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.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

public class Q2 {
	static FasterScanner sc;
	static int cnt=0;
	static boolean b[];
	static int[] arr;
	static ArrayList<Integer>[] amp;
	static StringBuilder s2;
	public static void main(String args[] ) throws Exception {
        sc=  new FasterScanner();
        BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
        String str = sc.nextLine();
        StringBuilder s = new StringBuilder();
        for(int i = 0 ;i < str.length()-1;i++) s.append(str.charAt(i));
        long abc = 0,ans = Long.parseLong(s.toString());
        if(ans%4!=0)
        abc = (ans/4)*16;
        else abc = (ans/4-1)*16;
        long x = ans%4;
        if(x==1 || x == 3){
        	if(str.charAt(str.length()-1)=='f') abc+=1;
        	if(str.charAt(str.length()-1)=='e') abc+=2;
        	if(str.charAt(str.length()-1)=='d') abc+=3;
        	if(str.charAt(str.length()-1)=='c') abc+=6;
        	if(str.charAt(str.length()-1)=='b') abc+=5;
        	if(str.charAt(str.length()-1)=='a') abc+=4;
        }
        if(x==0 || x == 2){
        	abc+=7;
        	if(str.charAt(str.length()-1)=='f') abc+=1;
        	if(str.charAt(str.length()-1)=='e') abc+=2;
        	if(str.charAt(str.length()-1)=='d') abc+=3;
        	if(str.charAt(str.length()-1)=='c') abc+=6;
        	if(str.charAt(str.length()-1)=='b') abc+=5;
        	if(str.charAt(str.length()-1)=='a') abc+=4;
        }
        System.out.println(abc);
        log.close(); 
   }
	
	public static void stringReverse(int s, int e){
		int i = s, j =e;
		char ch[] = s2.toString().toCharArray();
		while(i<j){
			char c = ch[i];
			ch[i] = ch[j];
			ch[j] = c;
			i++;j--;
		}
		s2.delete(0, s2.length());
		for(int x =0 ;x<ch.length;x++) s2.append(ch[x]);
	}
	public static void buildGraph(int m){
		for(int i = 0; i<m;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			amp[--x].add(--y);
			amp[y].add(x);
		}
	}
	public static boolean isPalindrome(String str){
	    int cnt = 0;
	    int arr[] = new int[26];
		for(int i =0;i<str.length();i++){
	        arr[str.charAt(i)-'a']++;
	    }
		for(int i = 0;i<26;i++){
			if(arr[i]%2==0) continue;
			else cnt++;
		}
		if(cnt<2)
	    return true;
		return false;
	}
	public static void dfs(int x,HashMap<Integer,Integer> hm){
		b[x] = true;
		if(hm.containsKey(arr[x]-1)) hm.put(arr[x]-1, hm.get(arr[x]-1)+1);
		else{
			hm.put(arr[x]-1, 1);
		}
		cnt++;
		for(int i =0;i<amp[x].size();i++){
			if(!b[amp[x].get(i)]) dfs(amp[x].get(i),hm);
		}
	}
	
	public static void mergeSort(int[] arr, int start, int end){
		
		if(start<end){
			int mid = (start+end)/2;
			mergeSort(arr,start,mid);
			mergeSort(arr,mid+1,end);
		merge(arr,start,mid,end);
		}
	}
	public static void merge(int arr[],int start, int mid, int end){
		int left[] = new int[mid-start+1];
		int right[] = new int[end-mid];
		for(int i= 0;i<mid-start+1;i++){
			left[i] = arr[i+start];
			//System.out.println(left[i-start]);
		}
		for(int i = 0;i<end-mid;i++){
			right[i] = arr[i+mid+1];
			//System.out.println(right[i-mid]+"*");
		}
		int k = start, i =0, j = 0;
		while(i<mid-start+1 && j<end-mid){
			if(left[i]<right[j]){
				arr[k++] = left[i];
				i++;
			}
			else{
				arr[k++] = right[j];
				j++;
			}
			
		}
		while(i<mid-start+1) {
			arr[k++] = left[i];i++;
		}
		while(j<end-mid) {
			arr[k++] = right[j];j++;
		}
	}
	
	
		
	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}
	        
	    public int[] nextIntArray(int n) {
	        return nextIntArray(n, 0);
	    }
	    
	    public int[] nextIntArray(int n, int off) {
	    	int[] arr = new int[n + off];
	    	for (int i = 0; i < n; i++) {
	    		arr[i + off] = nextInt();
	    	}
	    	return arr;
	    }
	    
	    public long[] nextLongArray(int n) {
	    	return nextLongArray(n, 0);
	    }
        
		public long[] nextLongArray(int n, int off) {
		    long[] arr = new long[n + off];
		    for (int i = 0; i < n; i++) {
		        arr[i + off] = nextLong();
		    }
		    return arr;
		}

	    private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}


}