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 ≤ 10^18) 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.

Difficulty: interview

Starter code:

Solutions:
seat = input()
time_to = {'a': 4, 'f': 1, 'b': 5, 'e': 2, 'c': 6, 'd': 3}
col = seat[-1]
row = int(seat[:-1])
row -= 1

blocks_to_serve = row // 4
time = (6 * 2 + 4) * blocks_to_serve

if row % 2 == 1:
    time += 6 + 1

time += time_to[col]

print(time)


# You lost the game.
s = str(input())
l = s[len(s)-1]
r = int(s[:len(s)-1]) - 1

D = {}
D["f"] = 1
D["e"] = 2
D["d"] = 3
D["a"] = 4
D["b"] = 5
D["c"] = 6

q = r // 4
b = r % 4

if b % 2 == 0:
    print(D[l]+16*q)
else:
    print(D[l]+16*q+7)


s = input()
n, p = int(s[:-1]), s[-1]
T = 16 * ((n - 1) // 4)
k = (n - 1) % 4 + 1
if k in (2, 4): T += 7
D = {'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}
T += D[p]
print(T)


s = input()
n = int(s[:-1]) - 1
s = s[-1]

res = n // 4 * (6 * 2 + 4)
if n % 2 == 1:
    res += 7
res += {'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}[s]
print(res)


time_in_row = [4, 5, 6, 3, 2, 1]

s_in = input()
n = int(s_in[:-1]) - 1
s = ord(s_in[-1]) - ord('a')

k = n // 4
ans = k * 16
ans += time_in_row[s]
if n % 2 == 1:
    ans += 7
print(ans)


pos = input()
row = int(pos[:-1]) - 1
place = pos[-1]

res = 0
res += (row // 4) * 16

if row % 2 != 0:
    res += 7

res += 'fedabc'.index(place) + 1

print(res)


3

s = input()
seat = s[-1]
n = int(s[:-1])

t = 1 + 16 * ((n - 1) // 4)

n = (1 - (n % 4) % 2)
t += n * 7

a = ['f', 'e', 'd', 'a', 'b', 'c']
t += a.index(seat)

print(t)


S=input()
R=int(S[:-1])
C=S[-1]
T=((R-1)//4)*16+((R-1)%2)*7
if C=='f':
    T+=1
if C=='e':
    T+=2
if C=='d':
    T+=3
if C=='a':
    T+=4
if C=='b':
    T+=5
if C=='c':
    T+=6
print(T)


s = input()
n = int(s[:-1])
s = s[-1]

n -= 1
ans = n // 4 * 16 + n % 2 * 7

for i in "fedabc":
    ans += 1
    if s == i: break

print(ans)

s = input()
n = int(s[:len(s) - 1])
n -= 1
ans = (n // 4) * 16
n %= 4
if n % 2 == 1:
    ans += 6 + 1
d = {'a':4,'f':1,'e':2,'d':3,'b':5,'c':6}
print(ans + d[s[-1]])


s = input()
pos = 0

f="0123456789"

for i in s :
    if i in f :
        pos+=1;
    else :
        break;

a=int(s[0:pos])
c=s[pos:]

d = {"f":1,"e":2,"d":3,"a":4,"b":5,"c":6}

t=a
a = (a+1)//2
a = (a+1)//2

print( 16*(a-1) + 7*(1-t%2) + d[c])


s = input()
n, c = int(s[:-1]), s[-1]
ans = (n-1) // 4 * (12 + 4)
mp = {
    'a': 4,
    'b': 5,
    'c': 6,
    'd': 3,
    'e': 2,
    'f': 1
}
ans += mp[c]

n -= (n-1) // 4 * 4

np = {
    1: 0,
    2: 7,
    3: 0,
    4: 7,
}

ans += np[n]

print(ans)


def get_ans(start):
    t = (start - 1) // 4
    ret = t * 16

    if (start - 1) % 4 in (1, 3):
        ret += 7

    return ret

s = input()

seat = int(s[:-1])
p = s[-1]

ans = get_ans(seat)

if p == 'f':
    ans += 0
elif p == 'e':
    ans += 1
elif p == 'd':
    ans += 2
elif p == 'a':
    ans += 3
elif p == 'b':
    ans += 4
elif p == 'c':
    ans += 5
ans += 1

print(ans)


a = input()
n = int(a[:-1])
s = a[-1]
ans = ((n-1)//4)*16
n -= ((n-1)//4)*4
d = {'f':1, 'e':2, 'd':3, 'a':4, 'b':5, 'c': 6}
if n in (1, 3):
    ans += d[s]
else: ans += 7 + d[s]
print(ans)

#import sys

#sys.stdin = open('input.txt', 'r')
#sys.stdout = open('output.txt', 'w')

s = input()
x = int(s[:len(s) - 1])
r = s[len(s) - 1]
x -= 1
kv = x // 4
ans = kv * 16
x -= kv * 4
if (x % 2 == 1):
    ans += 7
if (r == 'f'):
    ans += 1
if (r == 'e'):
    ans += 2
if (r == 'd'):
    ans += 3
if (r == 'a'):
    ans += 4
if (r == 'b'):
    ans += 5
if (r == 'c'):
    ans += 6
print(ans);


s = input()
n, s = int(s[:-1]) - 1, ord(s[-1]) - ord('a')

blocks = n // 4
n = n % 4
offs = (n % 2)

locOffs = [4, 5, 6, 3, 2, 1][s]

ans = blocks * 16 + offs * 7 + locOffs
print(ans)

seat = input()
row, seat = int(seat[:-1]), seat[-1]
row -= 1
shift = {'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}
time = shift[seat]
if row % 4 == 2:
    row -= 1
elif row % 4 == 1:
    row += 1
row //= 2
time += 6 * row
time += row
time += 2 * (row // 2)
print(time)

s = input()
l = s[-1]
s = int(s[:-1])
ez = '=fedabc'
if (s%4 == 3 or s%4 == 0):
    s -= 2
if s%4 == 1:
    print(16*(s//4)+ez.index(l))
elif s%4 == 2:
    print(7+16*(s//4)+ez.index(l))


s = input()
n = int(s[:-1])
s = s[-1:]
n -= 1
x = n // 4
ans = x * 16
n -= x * 4
d = dict()
d = {'f':1, 'e':2, 'd':3, 'a':4, 'b':5, 'c':6}
if n == 0 or n == 2:
    ans += d[s]
else:
    ans += (7 + d[s])
print(ans)


d = {'f' : 0, 'e' : 1, 'd' : 2, 'a' : 3, 'b' : 4, 'c' : 5}
s = input()
n = int(s[:-1])
if n % 4 in (1, 2):
    st = (n + 2) // 2
    hui = 0
else:
    st = n // 2
    hui = -2
print((st - 1) * 6 + n + hui + d[s[-1]])

s = input()
n = int(s[:-1])
last = s[-1]
if n % 4 in (1, 2):
    t = (n + 2) // 2
    b = 0
else:
    t = n // 2
    b = -2
bereza = {'f': 0, 'e': 1, 'd': 2, 'a': 3, 'b': 4, 'c': 5}
print((t - 1) * 6 + n + b + bereza[last])

seat_secs = {'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}

vasya = input()
row = int(vasya[:-1]) - 1
seat = vasya[-1]
seconds = 0
if row % 4 == 0 or row % 4 == 2: seconds += (row//4) * 16
else: seconds += (row//4) * 16 + 7
seconds += seat_secs[seat]
print(seconds)



s = input()
n = int(s[:-1])
s = s[-1]
n -= 1
ans = (16) * (n // 4) 
n %= 4
if n == 0:
    ans += 0
if n == 1:
    ans += 7
if n == 2:
    ans += 0
if n == 3:
    ans += 7
#print(ans)
if s in 'f':
    ans += 1
if s in 'e':
    ans += 2
if s in 'd':
    ans += 3
if s in 'a':
    ans += 4
if s in 'b':
    ans += 5
if s in 'c':
    ans += 6

print(ans)


x=input().strip();
n=int(x[:len(x)-1]);
c=x[len(x)-1];
#print(n);
#print(c);
ans=0;
ans+=((n-1)//4) * 16;
n%=4;

colVal=0;
if(c=='a'):
    colVal=4;
if(c=='b'):
    colVal=5;
if(c=='c'):
    colVal=6;
if(c=='d'):
    colVal=3;
if(c=='e'):
    colVal=2;
if(c=='f'):
    colVal=1;

if n==1 or n==3:
    ans+=colVal;
if n==2 or n==0:
    ans+=7;
    ans+=colVal;
print(ans);

l = input()
n = int(l[:-1])
s = l[-1]

d = {'a':4, 'b':5, 'c':6, 'd':3, 'e':2, 'f':1}

k = (n - 1) // 4
res = 16 * k
if n % 4 in [0, 2]:
    res += 7
res += d[s]
print(res)