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: EASY

Starter code:

Solutions:
(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, p) = map(int, input().split())
x = int(''.join(('10'[input() == 'half'] for _ in range(n)))[::-1], 2)
k = 0
while x:
	k += x / 2
	x //= 2
print(int(k * p))


(n, p) = map(int, input().split())
commands = []
for i in range(n):
	commands.append(input())
commands.reverse()
apples = 1
total = p // 2
for i in range(1, n):
	if commands[i] == 'halfplus':
		apples = apples * 2 + 1
		total += apples / 2 * p
	else:
		total += apples * p
		apples *= 2
print(int(total))


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)

def hnbhai():
	(n, p) = sd()
	x = []
	for i in range(n):
		s = sa()
		if s == 'half':
			x.append(0)
		else:
			x.append(1)
	ans = 0
	tot = 0
	for i in range(n - 1, -1, -1):
		if x[i] == 1:
			tot += 0.5
		ans += tot
		tot *= 2
	print(int(ans * p))
for _ in range(1):
	hnbhai()


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


(n, p) = [int(x) for x in input().split()]
a = []
f = 1
for i in range(1, n + 1):
	b = input()
	if b == 'half':
		a.append(1)
	else:
		a.append(2)
s = p
for i in range(n - 2, -1, -1):
	if a[i] == 1:
		s = s * 2
	else:
		s = (s + p // 2) * 2
		f += 1
s = s - p // 2 * f
print(int(s))


(n, p) = 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) = list(map(int, input().split()))
l = list()
for i in range(n):
	l.append(input())
l = reversed(l)
x = 0
ans = 0
for i in list(l):
	if i == 'half':
		ans += x * p
		x *= 2
	else:
		ans += x * p + 0.5 * p
		x = x * 2 + 1
print(int(ans))


import math, re, sys, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
pi = math.acos(-1.0)
MAX = 100
(n, p) = RI()
p //= 2
val = 0
for i in range(n):
	s = RS()[0]
	if s == 'halfplus':
		val += 2 ** i
ans = 0
while val:
	ans += val * p
	val //= 2
print(ans)


from math import ceil
(n, p) = 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 collections import defaultdict
import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
(n, p) = map(int, input().split())
l = [input() for i in range(n)][::-1]
f = 1
np = 1
for i in range(1, n):
	if l[i] == 'halfplus':
		f = f * 2 + 1
		np += 1
	else:
		f *= 2
print(p * f - p * np // 2)


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(a) for a in input().strip().split()]
b = []
for i in range(n):
	b.append(input().strip())
m = 0
last_number = 0
while b:
	s = b.pop()
	if s == 'half':
		m += last_number * p
		last_number *= 2
	else:
		m += (last_number + 0.5) * p
		last_number += 0.5
		last_number *= 2
print(int(m))


(n, p) = map(int, input().split())
S = []
for _ in range(n):
	tmp = input()
	S += [0 if tmp == 'half' else 1]
S.reverse()
amount = 0
result = 0
for i in S:
	if i:
		result += p * amount + p // 2
		amount = 2 * amount + 1
	else:
		result += p * amount
		amount = 2 * amount
print(result)


(n, p) = map(int, input().split())
(ans, cnt) = (0, 0)
for s in reversed(list((input() for _ in range(n)))):
	if s == 'halfplus':
		ans = ans << 1 | 1
		cnt += 1
	else:
		ans = ans << 1
print(ans * p - cnt * p // 2)


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


(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, k) = map(int, input().split())
tot = 0
h = 0
l = []
for _ in range(n):
	a = input()
	if a == 'half':
		l.append(0)
	else:
		l.append(1)
		h += 1
l.reverse()
for i in l:
	if i == 1:
		tot *= 2
		tot += 1
	else:
		tot *= 2
print(tot * k - h * k // 2)


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)


(n, p) = map(int, input().split())
s = sum((1 << i for i in range(n) if 's' in input()))
print(sum((s >> i for i in range(n))) * p >> 1)


(n, p) = map(int, input().split())
b = []
for i in range(n):
	r = input()
	b.append(r)
earned = 0
apples = 0
for i in b[::-1]:
	if len(i) != 4:
		apples += 1
		earned += apples / 2.0 * p
	else:
		earned += apples // 2 * p
	apples *= 2
print(int(earned))


(n, p) = map(int, input().split())
L = []
for i in range(n):
	L.append(input())
apple = 0
money = 0
while L != []:
	k = L.pop()
	if k == 'halfplus':
		money += apple + 0.5
		apple = 2 * apple + 1
	else:
		money += apple
		apple = 2 * apple
print(int(money * p))


(n, p) = map(int, input().split())
x = 0
b = [0 if input() == 'half' else 1 for i in range(n)]
b.reverse()
cnt = sum(b)
x = 0
for bit in b:
	x = (x << 1) + bit
print(x * p - cnt * p // 2)


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


(n, p) = 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)


aa = [int(num) for num in input().split()]
(n, p) = (aa[0], aa[1])
sales = [None] * n
for i in range(n):
	sales[i] = 1 if input() == 'halfplus' else 0
T = 0
for j in range(len(sales)):
	T += sales[j] * 2 ** j
result = p * (T - sum(sales) / 2)
print(int(result))


(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))))


(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, p) = [int(x) for x in input().split()]
a = [0 if len(input()) == 4 else 1 for i in range(n)]
num = ans = 0
for i in range(n - 1, -1, -1):
	if a[i]:
		ans += p * num
		ans += p // 2
		num = num * 2 + 1
	else:
		ans += p * num
		num *= 2
print(ans)


(n, p) = map(int, input().split(' '))
ps = [True if input() == 'halfplus' else False for _ in range(n)]
t = 0
result = 0
for x in reversed(ps):
	if x:
		t += 0.5
	result += t
	t *= 2
print(int(result * p))


(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)


import re
a = re.split(' ', input())
p = int(a[1])
buyers = []
for i in range(0, int(a[0])):
	if input() == 'half':
		buyers.append(True)
	else:
		buyers.append(False)
c = 0
x = 0
for i in range(len(buyers) - 1, -1, -1):
	if buyers[i] == False:
		x = 2 * x + 1
	else:
		x = 2 * x
	c += p * x / 2
print(int(c))


f = lambda : input().split()
(n, p) = (int(x) for x in f())
mlist = []
for i in range(n):
	mlist.append(input())
apple = 0
for i in mlist[::-1]:
	if i == 'halfplus':
		apple = 2 * apple + 1
	else:
		apple = 2 * apple
ans = 0
for i in mlist:
	if i == 'half':
		ans += apple // 2 * p
		apple //= 2
	else:
		ans += apple / 2 * p
		apple //= 2
print(int(ans))


(N, P) = map(int, input().split())
S = [0 for _ in range(N)]
for i in range(N):
	if input() == 'halfplus':
		S[i] = 1
apple = 0
money = 0
for i in range(N)[::-1]:
	money += apple * P
	apple *= 2
	if S[i]:
		apple += 1
		money += P // 2
print(money)


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


(m, n) = map(int, input().split())
lista = []
valor = 0.5
cont = 0
for i in range(m):
	nome = input()
	lista.append(nome)
for x in range(2, m + 1):
	if lista[-x] == 'halfplus':
		valor = 2 * valor + 0.5
		cont += valor
	else:
		valor = 2 * valor
		cont += valor
print(int((cont + 0.5) * n))


__author__ = 'SLAUUUIK'
(n, p) = map(int, input().split())
num = 0
money = 0
v = []
for i in range(n):
	v.append(input())
v = v[::-1]
for i in range(n):
	if v[i] == 'half':
		num *= 2
	else:
		num = num * 2 + 1
		money -= 0.5 * p
print(int(num * p + money))


(n, p) = map(int, input().split())
customers = [input() for i in range(n)]
summa = p // 2
last_quantity = 1
customers = customers[:-1]
for customer in customers[-1::-1]:
	quantity = last_quantity * 2
	if customer == 'halfplus':
		quantity += 1
	last_quantity = quantity
	summa += quantity * p // 2
print(summa)


(n, c) = [int(i) for i in input().split()]
operations = []
for i in range(n):
	op = input()
	if op == 'halfplus':
		operations.append('hp')
	else:
		operations.append('h')
operations = list(reversed(operations))
half_count = 0
p = 0
for op in operations:
	if op == 'hp':
		half_count += 1
		p = 2 * p + 1
	else:
		p = 2 * p
print(int(c * (p - 0.5 * half_count)))


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
(n, p) = il()
a = []
for i in range(n):
	x = ip()
	if x == 'half':
		a.append(False)
	else:
		a.append(True)
a.reverse()
ans = 0
t = 0
for i in a:
	if i:
		t += 0.5
	ans += t
	t *= 2
print(int(ans * p))


(n, p) = map(int, input().split(' '))
l = []
for x in range(n):
	pp = input()
	l.append(pp)
l.reverse()
a = [1 for x in range(n)]
ans = 0.5 * p
for x in range(1, n):
	if l[x] == 'halfplus':
		a[x] = a[x - 1] * 2 + 1
		ans = ans + int(a[x] / 2 * p)
	else:
		a[x] = a[x - 1] * 2
		ans = ans + int(a[x] // 2) * p
print(int(ans))


def main():
	(n, p) = (int(x) for x in input().split())
	buyers = [None] * n
	for i in range(n):
		buyers[i] = input()
	print(solver(p, buyers))

def solver(p, L):
	apples = 0
	money = 0
	for i in range(len(L) - 1, -1, -1):
		h = L[i]
		if h == 'half':
			apples *= 2
		elif h == 'halfplus':
			apples = 2 * apples + 1
		else:
			assert False
		money += apples / 2 * p
	return int(money)
main()


(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(' '))
s = [input() for i in range(n)][::-1]
apple = 0
money = 0
for line in s:
	if line == 'halfplus':
		apple = apple * 2 + 1
	elif line == 'half':
		apple = apple * 2
	money += p // 2 * apple
print(money)


(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)


plus = 0
cnt = 0
a = []
(n, p) = map(int, input().split())
for i in range(n):
	a.append(input())
for i in reversed(range(n)):
	if a[i] == 'halfplus':
		plus += 0.5
		cnt = cnt * 2 + 1
	else:
		cnt *= 2
print(int((cnt - plus) * p))


from sys import stdin
(N, P) = map(int, stdin.readline().strip().split(' '))
sales = [len(stdin.readline()) for n in range(N)]
apples = 0
profit = 0
for x in reversed(sales):
	if x == 5:
		profit += P * apples
		apples *= 2
	else:
		profit += P * (apples + 0.5)
		apples += 0.5
		apples *= 2
print(round(profit))


(n, p) = [int(i) for i in input().split()]
i = 0
a = []
while i < n:
	a.append('half' != input())
	i += 1
s = c = 0
for x in a[::-1]:
	s += c * p + x * p // 2
	c = c * 2 + x
print(s)


(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())
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())
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, p) = list(map(int, input().strip().split()))
s = []
for i in range(n):
	a = str(input())
	if a == 'half':
		s.append(0)
	else:
		s.append(1)
s = s[::-1]
m = 1
for i in range(1, n):
	m *= 2
	m += s[i]
s = s[::-1]
q = 0
for i in range(n):
	q += m
	m = m // 2
print(q * p // 2)


array = []
(num1, num2) = map(int, input().split())
for i in range(num1):
	array.append(input())
count = 0
c = 1
for i in range(num1 - 1, -1, -1):
	if array[i] == 'halfplus':
		if c == 1:
			count += c / 2
			c = c * 2
		else:
			c += 1
			count += c / 2
			c = c * 2
	else:
		count += c / 2
		c = c * 2
print(int(count * num2))


def main():
	(n, p) = map(int, input().split())
	res = x = 0
	for f in reversed([input() == 'halfplus' for _ in range(n)]):
		res += x * 2
		x *= 2
		if f:
			res += 1
			x += 1
	print(res * p // 2)
main()


(n, p) = map(int, input().split())
a = []
for _ in range(n - 1):
	a.append(input())
input()
apples = 1
for x in reversed(a):
	if x == 'half':
		apples *= 2
	elif x == 'halfplus':
		apples *= 2
		apples += 1
a.append('halfplus')
ans = 0
for x in a:
	if x == 'half':
		ans += p * (apples / 2)
		apples /= 2
	elif x == 'halfplus':
		ans += p * (apples / 2)
		apples //= 2
assert apples == 0
print(int(ans))


def function():
	temp = input().split()
	customers = int(temp[0])
	cost = int(temp[1])
	custArray = []
	for customer in range(customers):
		temp = input()
		custArray.append(temp)
	apples = 0
	profit = 0
	for index in range(customers):
		if custArray[customers - 1 - index] == 'half':
			if apples == 0:
				apples = 1
				profit = cost
			else:
				profit += cost * apples
				apples = 2 * apples
		elif apples == 0:
			apples = 1
			profit = cost / 2
		else:
			profit += (apples + 0.5) * cost
			apples = apples * 2 + 1
	return int(profit)
print(function())


(a, b) = map(int, input().split())
z = [input() for i in ' ' * a]
s = 1
o = z.copy()
z.pop()
z = z[::-1]
for i in z:
	if i == 'half':
		s = s * 2
	else:
		s = s * 2 + 1
k = 0
for i in o:
	if i == 'half':
		k += s // 2 * b
		s //= 2
	else:
		k += s // 2 * b + b // 2
		s //= 2
print(k)


(b, p) = map(int, input().split())
buys = []
apples = 0
aSold = 0
for i in range(b):
	buys.append(input())
for i in buys[::-1]:
	if i == 'halfplus':
		aSold += apples + 0.5
		apples = apples * 2 + 1
	else:
		aSold += apples
		apples *= 2
print(int(aSold * p))


(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)


import sys
(n, p) = map(int, input().split())
a = [input() for _ in range(n)]
assert a[-1] == 'halfplus'
ans = p >> 1
cnt = 1
for s in a[-2::-1]:
	if s == 'half':
		ans += cnt * p
		cnt <<= 1
	else:
		ans += cnt * p + (p >> 1)
		cnt += cnt + 1
print(ans)


(n, p) = [int(i) for i in input().split()]
a = ['half' != input() for _ in range(n)]
s = c = 0
for x in a[::-1]:
	s += c * p + x * p // 2
	c = c * 2 + x
print(s)


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


(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))


(n, p) = list(map(int, input().split()))
s = ''
for _ in range(n):
	a = input()
	if a == 'half':
		s += '0'
	else:
		s += '1'
s = ''.join(reversed(s))
b = int(s, 2)
k = 0
while b > 0:
	if b % 2 == 0:
		k += b // 2 * p
		b = b // 2
	else:
		k += b / 2 * p
		b = b // 2
print(int(k))


(n, p) = map(int, input().split())
A = []
for i in range(n):
	A.append(input())
A.reverse()
res = 0
cnt = 0
for x in A:
	if x == 'halfplus':
		res += (cnt + 0.5) * p
		cnt = 2 * cnt + 1
	else:
		res += cnt * p
		cnt = 2 * cnt
print('%.0f' % res)


[n, p] = [int(x) for x in input().split(' ')]
o = []
for i in range(0, n):
	o.append(input())
f = 0
a = 0
for j in reversed(o):
	if j == 'halfplus':
		a += (f + 0.5) * p
		f = (f + 0.5) * 2
	elif j == 'half':
		a += f * p
		f = f * 2
print(int(a))


I = input
(n, p) = map(int, I().split())
a = k = 0
for i in [4 < len(I()) for _ in ' ' * n][::-1]:
	k += a * p + i * p // 2
	a = a * 2 + i
print(k)


(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)


(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))


def solve(buyers):
	total_apples = 0
	total_earned = 0
	for cur in reversed(buyers):
		if cur == 'halfplus':
			total_apples = total_apples * 2 + 1
		else:
			total_apples = total_apples * 2
		total_earned += total_apples / 2 * p
	return int(total_earned)
(n, p) = map(int, input().split(' '))
buyers = [input() for i in range(n)]
print(solve(buyers))


(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))


def solve():
	(N, P) = 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)
solve()


(n, p) = map(int, input().split())
sales = [input() for i in range(n)]
(profit, total_apples) = (0, 0)
for i in range(n - 1, -1, -1):
	if sales[i] == 'halfplus':
		profit += (total_apples + 0.5) * p
		total_apples = total_apples * 2 + 1
	else:
		profit += total_apples * p
		total_apples *= 2
print(int(profit))


(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) = map(int, input().split())
p //= 2
m = s = 0
k = [input() for i in range(n)]
k.reverse()
for i in k:
	m *= 2
	if i == 'halfplus':
		m += 1
	s += m
print(s * p)


from sys import maxsize as m
(n, p) = map(int, input().split(' '))
c = m
buyer = []
cost = {}
for i in range(n):
	buyer += [input()]
a = 1
for i in range(n - 2, -1, -1):
	if buyer[i] == 'half':
		a = 2 * a
	elif buyer[i] == 'halfplus':
		a = 2 * a + 1
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))


(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))


import math
(rows, price) = map(int, input().split())
array = []
for i in range(rows):
	s = input()
	array.append(s)
array = array[::-1]
result = 1
counter = 0.5
for i in array[1:]:
	if i == 'half':
		result = result * 2
	else:
		result = result * 2 + 1
		counter += 0.5
print(int((result - counter) * price))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import *
from itertools import accumulate
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
arr = [ip() for i in range(n)]
arr = arr[::-1]
c = 0
ans = []
for i in arr:
	if i == 'halfplus':
		c = c * 2 + 1
	else:
		c = c * 2
	ans.append(c)
print(k * sum(ans) // 2)


def f(n, p, nos):
	x = 1
	for i in range(1, n):
		x = 2 * x + 1 if nos[i] else 2 * x
	print(x * p - p * sum(nos) // 2)
(n, p) = input().split(' ')
(n, p) = (int(n), int(p))
nos = []
for _ in range(n):
	nos.append(input() == 'halfplus')
nos = nos[::-1]
f(n, p, nos)