Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.

She precisely remembers she had n buyers and each of them bought exactly half of the apples she had at the moment of the purchase and also she gave a half of an apple to some of them as a gift (if the number of apples at the moment of purchase was odd), until she sold all the apples she had.

So each buyer took some integral positive number of apples, but maybe he didn't pay for a half of an apple (if the number of apples at the moment of the purchase was odd).

For each buyer grandma remembers if she gave a half of an apple as a gift or not. The cost of an apple is p (the number p is even).

Print the total money grandma should have at the end of the day to check if some buyers cheated her.


-----Input-----

The first line contains two integers n and p (1 ≤ n ≤ 40, 2 ≤ p ≤ 1000) — the number of the buyers and the cost of one apple. It is guaranteed that the number p is even.

The next n lines contains the description of buyers. Each buyer is described with the string half if he simply bought half of the apples and with the string halfplus if grandma also gave him a half of an apple as a gift.

It is guaranteed that grandma has at least one apple at the start of the day and she has no apples at the end of the day.


-----Output-----

Print the only integer a — the total money grandma should have at the end of the day.

Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.


-----Examples-----
Input
2 10
half
halfplus

Output
15

Input
3 10
halfplus
halfplus
halfplus

Output
55



-----Note-----

In the first sample at the start of the day the grandma had two apples. First she sold one apple and then she sold a half of the second apple and gave a half of the second apple as a present to the second buyer.

Difficulty: interview

Starter code:

Solutions:
n,p = list(map(int,input().split()))
temp = [input() for i in range(n)]
num = 0
num2 = 0
for i in range(n-1,-1,-1):
    if temp[i] == "halfplus":
        num *= 2
        num += 1
        num2 += num/2*p
    else:
        num2 += num*p
        num *= 2
print(int(num2))
        
        


n, p = map(int, input().split())
A = []
for i in range(n):
    s = input()
    A.append(2 if s == 'half' else 1)

A.pop()
A = A[::-1]

h = p // 2
ans = h
c = 1
for i in range(n - 1):
    if A[i] == 1:
        ans += p * c + h
        c = c * 2 + 1 
    else:
        ans += c * p
        c *= 2
print(ans)

3

(n, p) = tuple(map(int, input().split()))
buyers = list()
for i in range(n):
	buyers.append(input())
total = 0
money = 0
for i in range(n-1, -1, -1):
	if buyers[i] == 'halfplus':
		total = (total + 0.5) * 2
		money += p * total * 0.5
	else:
		total = total * 2
		money += p * total * 0.5
print(str(int(money)))


n, p = map(int, input().split())
total = 0
sold = 0.0
log = []
for i in range(n):
	log.append(input() == 'half')
for x in reversed(log):
	if x:
		total *= 2
		sold += (total / 2)
	else:
		total = total * 2 + 1
		sold += (total / 2)

print(int(sold * p))

import collections
import math

n, p = map(int, input().split())
t = [input() for _ in range(n)]
t = t[::-1]
ans, apple = p // 2, 1
for i in range(1, n):
    if t[i] == 'halfplus':
        ans += apple * p + p // 2
        apple += apple + 1
    else:
        ans += apple * p
        apple *= 2
print(ans)

def solve():
    N, P = list(map(int, input().split()))
    m = []
    for i in range(N):
        s = input()
        m.append(s)

    m.reverse()

    cur = 0
    ans = 0
    for s in m:
        if s == 'halfplus':
            nex = cur * 2 + 1
        else:
            nex = cur * 2
        ans += nex * P // 2
        cur = nex

    print(ans)


def __starting_point():
    solve()

__starting_point()

n, p = list(map(int, input().split()))
a = [input() for i in range(n)]
cur = 1
cnt = 1
for i in a[-2::-1]:
    if i == 'halfplus':
        cur = cur * 2 + 1
        cnt += cur
    else:
        cur *= 2
        cnt += cur
print(cnt * p // 2)


n,p = map(int,input().split())
li = []
for _ in range(n):
	s = input()
	li.append(s)
li=li[::-1]
count=0
total=0
for i in li:
	if i == 'halfplus':
		count = count*2 + 1
		total = total + int((count/2)*p)
	else:
		count = count*2
		total = total + int((count/2)*p)
print(total)		

n, m = list(map(int, input().split()))
a = []
for i in range(n):
    s = input()
    if s == 'half':
        a.append(1)
    else:
        a.append(2)

def check(x):
    for i in range(n):
        if x == 0:
            return 0
        if a[i] == 1:
            x = x / 2
        else:
            x = x / 2 - 0.5
    if x < 0:
        return 0
    return 1

l = 0
r = 2**100
while l < r - 0.1:
    x = (l + r) / 2
    if check(x):
        r = x
    else:
        l = x
cnt = 0
for i in range(n):
    if a[i] == 2:
        cnt += 0.5
print(int(r * m - cnt * m))


n, p = input().split()
n, p = int(n), int(p)

money = 0

apples = 0

pohyby = []
for _ in range(n):
    pohyby.append(input())

for pos, pohyb in enumerate(reversed(pohyby)):
    if pohyb == "half":
        apples *= 2
        money += apples / 2 * p
    elif pos == 0:
        apples = 1
        money += p / 2
    else:
        apples = apples * 2 + 1
        money += apples / 2 * p

print(int(money))

n, p = [int(x) for x in input().split()]
guys = [input() == 'halfplus' for i in range(n)]
cur = 0
S = 0
for guy in reversed(guys):
    S += p*cur + guy*p//2
    cur = 2 * cur + 1 if guy else 2 *  cur
print(S)


n, p = map(int, input().split())
data = [input() for i in range(n)]
q = 0
pol = 0
for elem in data[::-1]:
    if elem == 'halfplus':
        pol += 1
        q += 0.5
        q *= 2
    else:
        q *= 2
print(int(q * p - pol * p / 2))

n, p = list(map(int, input().split()))
l = []
for i in range(n):
    l.append(input())
apples = 0
welth = 0
for i in range(n - 1, -1, -1):
    if l[i] == 'halfplus':
        apples = apples * 2 + 1
    else:
        apples = apples * 2
    welth += apples * p // 2

print(welth)


n, p = list(map(int, input().split()))
apple = 0
operations = [input() for i in range(n)][::-1]
for i in operations:
    if len(i) == 4:
        apple *= 2
    else:
        apple = apple * 2 + 1
result = 0
while apple != 0:
    if apple % 2 == 0:
        apple //= 2
        result += p * apple
    else:
        result += (p * apple) // 2
        apple //= 2
print(result)


n, price = map(int, input().split())
history = []
ans = 0
cnt = 0
for i in range(n):
    history.append(input())
for s in history[::-1]:
    if s == 'halfplus':
        cnt = cnt * 2 + 1
    else:
        cnt *= 2
    ans += cnt / 2 * price
print(int(ans))

buyers, price = [int(item) for item in input().split()]
purchases = [input() for _ in range(buyers)]
apples = 0
for purchase in purchases[::-1]:
    if purchase == 'halfplus':
        apples = (apples + 0.5) * 2
    else:
        apples *= 2
print(int((apples - 0.5 * purchases.count('halfplus')) * price))

n, k = map(int, input().split())
answer = [0] * n
for i in range(n):
    per = input()
    answer[-(i+1)] =  1 if per == 'halfplus' else 0
per = 0
ans = 0
for i in range(0, n):
    if answer[i] == 1:
        ans += (per * k) + (k//2)
        per = per*2 + 1
    else:
        ans += (per * k)
        per = per * 2
print(ans)

n, p = list(map(int, input().split()))
s = []
for i in range(n):
    s.append(input().strip())
cnt = 0
ans = 0
for c in reversed(s):
    ans += p * cnt
    cnt *= 2
    if c == 'halfplus':
        cnt += 1
        ans += p//2
print(ans)


n, p = map(int, input().split())
a = sum(1 << i for i in range(n) if input() == 'halfplus')
print(sum(a // (1 << i) * p // 2 for i in range(n)))

#!/usr/bin/env python3

n, p = list(map(int, input().split()))
arr = [input() for _ in range(n)]
arr.reverse()

money = 0
apples = 0
for line in arr:
    if line == 'halfplus':
        money += apples*2 + 1
        apples = apples*2 + 1
    else:
        money += apples*2
        apples = apples*2

print(money*p//2)


from math import ceil

n, p = list(map(int, input().split()))
bs = [input() for i in range(n)]

apples = 0
money = 0
for b in bs[::-1]:
    apples *= 2
    if b == 'halfplus':
        apples += 0.5
        apples = ceil(apples)
        
    money += apples / 2 * p

print(int(money))


from sys import maxsize as m
def __starting_point():
    n,p = list(map(int,input().split(' ')))

    c = m
    buyer = []
    cost = {}
    for i in range(n):
        buyer += [input()]
    #buyer.reverse()
    a = 1   #last will always be halfplus
    for i in range(n-2,-1,-1):
        if buyer[i]=='half':
            a = 2*a
        elif buyer[i]=='halfplus':
            a = 2*a+1
    
    #buyer.reverse()
    cost = 0
    for i in range(n):
        if a%2==0:
            if buyer[i]=='half':
                cost += p*(a/2)
                a/=2
            elif buyer[i]=='halfplus':
                cost += p*(a/2 - 1/2)
                a = int(a/2 - 1/2)
        else:
            cost += p*(a/2)
            a = int(a/2 - 1/2)
    print(int(cost))
            
    
            
        

__starting_point()

money = 0
apples = 0
customers = []

num_customers, apple_price = [ int(x) for x in (input().split(' ')) ]


for i in range(0,num_customers):
    arg = input()
    customers.append(arg)

customers = reversed(customers)

for c in customers:
    if c == 'halfplus':
        money += (apples+0.5)*float(apple_price)
        apples = 2*apples+1
    elif c == 'half':
        money += (apples)*float(apple_price)
        apples = 2*apples

print(int(money))

n, p = (int(_) for _ in input().split())
a = [input() for i in range(n)][::-1]
ans = 0
apple = 0
for s in a:
    apple *= 2
    if s == 'halfplus':
        apple += 1
    ans += p * apple // 2
print(ans)