Problem:
 Score : 200 points    Problem Statement  Niwango created a playlist of N songs.
The title and the duration of the i -th song are s_i and t_i seconds, respectively.
It is guaranteed that s_1,\ldots,s_N are all distinct.  Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.)
However, he fell asleep during his work, and he woke up after all the songs were played.
According to his record, it turned out that he fell asleep at the very end of the song titled X .  Find the duration of time when some song was played while Niwango was asleep.      Constraints   1 \leq N \leq 50  s_i and X are strings of length between 1 and 100 (inclusive) consisting of lowercase English letters.  s_1,\ldots,s_N are distinct.  There exists an integer i such that s_i = X .  1 \leq t_i \leq 1000  t_i is an integer.         Input  Input is given from Standard Input in the following format:  N  s_1  t_1  \vdots  s_{N}  t_N  X       Output  Print the answer.        Sample Input 1 3
dwango 2
sixth 5
prelims 25
dwango      Sample Output 1 30   While Niwango was asleep, two songs were played: sixth and prelims .  The answer is the total duration of these songs, 30 .        Sample Input 2 1
abcde 1000
abcde      Sample Output 2 0   No songs were played while Niwango was asleep.  In such a case, the total duration of songs is 0 .        Sample Input 3 15
ypnxn 279
kgjgwx 464
qquhuwq 327
rxing 549
pmuduhznoaqu 832
dagktgdarveusju 595
wunfagppcoi 200
dhavrncwfw 720
jpcmigg 658
wrczqxycivdqn 639
mcmkkbnjfeod 992
htqvkgkbhtytsz 130
twflegsjz 467
dswxxrxuzzfhkp 989
szfwtzfpnscgue 958
pmuduhznoaqu      Sample Output 3 6348

Solution (Python):
N = int(input())
s_list = []
t = []
for i in range(N):
    a, n = input().split()
    s_list.append(a)
    t.append(int(n))
X = input()

times = 0
flag = False
for i, s in enumerate(s_list):
    if flag:
        times += t[i]
    if X == s:
        flag = True

print(times)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
  input_line = input().split()
  s.append(str(input_line[0]))
  t.append(int(input_line[1]))
  
x = input()

sum_bool = False
sum_song = 0
for j in range(n):
  if sum_bool == True:
    sum_song = sum_song + t[j]
  if x == s[j]:
    sum_bool = True
print(sum_song)

Solution (Python):
n = int(input())
s=[]
t=[]
for i in range(n):
    str = input().split()
    s.append(str[0])
    t.append(int(str[1]))
x=input()
total=0
if s.index(x)+1!=len(t):
    total=sum(t[s.index(x)+1:])
print(total)

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())

m = []
l = []

for _ in range(N):
    i = input().split()
    m.append(i[0])
    l.append(int(i[1]))

s = input().strip()
index = 0
for i, x in enumerate(m):
    if x == s:
        index = i + 1
        break

print(sum(l[index:]))

Solution (Python):
N = int(input())
play = list()
for i in range (N):
  play.append(input())
X = input()
j = 0
name = list()
time = list()
while j < N:
  kyoku = list(play[j].split())
  name.append(kyoku[0])
  time.append(int(kyoku[1]))
  j += 1

A = 0
k = name.index(X) + 1
while k < N:
  A += time[k]
  k += 1

print(A)

Solution (Python):
num=int(input()) 
song=[]
length=[]
for i in range(num):
  n, m = input().split()
  song.append(n)
  length.append(int(m))
last=str(input())
songindex=song.index(last)
print(sum(length[songindex+1:num]))

Solution (Python):
N = int(input())
mlist = [[]] * N
for i in range(N):
  mlist[i]  = list(map(str, input().split()))
X = str(input())
for j in range(N):
  if mlist[j][0] == X:
    mNo = range(j+1, N)
print(sum(int(mlist[k][1]) for k in mNo ))

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
        n = int(lines[0])
        for i in range(n):
            lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        n = int(lines[0])
    
    st = []
    for i in range(1, n+1):
        (s, t) = lines[i].split(" ")
        st.append((s, int(t)))
    x = lines[n+1]

    return (n, st, x)


def solve(n, st, x):

    index = None
    for i in range(n):
        (s, _) = st[i]
        if s == x:
            index = i
    
    st2 = st[index + 1:]
    result = sum([e[1] for e in st2])

    return result


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Solution (Python):
n = int(input())
s = [None for _ in range(n)]
t = [None for _ in range(n)]
for i in range(n):
    l = [i for i in input().split()]
    s[i] = l[0]
    t[i] = int(l[1])
x = input()

a = s.index(x)
res = 0
for i in range(a + 1, n):
    res += t[i]
print(res)

Solution (Python):
N = int(input())


s = [input().split() for i in range(N)]
X = input()
sleep_time = 0

for i in range(N):
  s[i][1] = int(s[i][1])
  if s[i][0] == X:
    I = i

for i in range(I + 1, N):
  sleep_time += s[i][1]

print(sleep_time)

Solution (Python):
N = int(input())
s = []; t = []
for i in range(N):
    s_tmp, t_tmp = input().split()
    s.append(str(s_tmp))
    t.append(int(t_tmp))
X = str(input())

start = s.index(X)
ans = 0
if start < N - 1:
    ans = sum(t[start + 1:])
print(ans)

Solution (Python):
N = int(input())
s_list = []
t_list = []

for i in range(N):
    s,t = input().split()
    s_list.append(s)
    t_list.append(int(t))

X = input()
del t_list[:s_list.index(X)+1]

print(sum(t_list))

Solution (Python):
def f(s):
  lst = s.split()
  return lst[0], int(lst[1])

N = int(input())
S = []
T = []
for i in range(N):
  s, t = f(input())
  S.append(s)
  T.append(t)

X = str(input())

if X in S:
  index = S.index(X)
else:
  print(o)

sum = 0
for i in range(index+1, N):
  sum += int(T[i])

print(sum)

Solution (Python):
def main():
    N = int(input())
    S = ["" for i in range(N)]
    T = ["" for i in range(N)]

    for i in range(N):
        s_t = input().split()
        S[i] = s_t[0]
        T[i] = int(s_t[1])

    X = input()

    total = 0
    sleep = False

    for i in range(N):
        if sleep:
            total += T[i]
        if not sleep and S[i] == X:
            sleep = True

    print(total)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
s = []
t = []

for i in range(0, n):
    si, ti = map(str, input().split())
    s.append( si)
    t.append( int(ti) )

x = input()

sum = 0
sleeping = False
for i in range(0, n):
    if sleeping:
        sum += t[i]
    if s[i] == x:
        sleeping = True

print(sum)

Solution (Python):
import sys

f = sys.stdin
N = int(f.readline())
T = []
S = {}
for i in range(N):
    s, t = f.readline().split(' ')
    T.append(int(t))
    S[s] = i
X = f.readline()[:-1]
time = sum(T[S[X]+1:])
print(time)

Solution (Python):
from collections import defaultdict, deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys
import random
import itertools
import math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt


def LI(): return list(map(int, input().split()))


def LF(): return list(map(float, input().split()))


def LI_(): return list(map(lambda x: int(x)-1, input().split()))


def II(): return int(input())


def IF(): return float(input())


def LS(): return list(map(list, input().split()))


def S(): return list(input().rstrip())


def IR(n): return [II() for _ in range(n)]


def LIR(n): return [LI() for _ in range(n)]


def FR(n): return [IF() for _ in range(n)]


def LFR(n): return [LI() for _ in range(n)]


def LIR_(n): return [LI_() for _ in range(n)]


def SR(n): return [S() for _ in range(n)]


def LSR(n): return [LS() for _ in range(n)]


def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]


def sosu(x):
    for i in range(2, int(sqrt(x)+1)):
        if x % i == 0:
            return False
    return True


mod = 1000000007
inf = float('INF')


def A():
    N = II()
    SS=[]
    T=[]
    for i in range(N):
        s, t = input().split()
        t=int(t)
        SS.append(s)
        T.append(t)
    X=input().rstrip()
    i=SS.index(X)+1
    ans=0

    while(1):
        if i>=(len(T)):
            break
        ans+=T[i]
        i+=1
    print(ans)

    return




def B():
    S = input()
    S = S[:-1]
    count = 0
    for i in range(len(S)//2):
        if (S[i] != S[-1-i]):
            count += 1

    print(count)
    return




def true():
    S = input()
    S = S[:-1]

    tmp = 0
    for x in range(1 << (len(S)-1)):
        func = S[-1]
        for i in range(len(S)-1):
            if(x & (1 << i)):
                tmp += int(func)
                func = S[-2-i]
            else:
                func = S[-2-i]+func
        tmp += int(func)
    print(tmp)

    return


def C():
    N = II()
    L = []
    for i in range(1, N+1):
        A = II()

        for j in range(A):
            x, y = LI()
            L.append([i, x, y])





def D():

    a, b, x = LI()
    BIG = a*a*b/2
    if x > BIG:
        y = 2*b-(2*x/a/a)
        print(math.degrees(math.atan(y/a)))
    else:
        y = 2*x/a/b
        print(math.degrees(math.atan(b/y)))
    return




def E():
    N, K = LI()
    A = LI()
    F = LI()
    A.sort(reverse=True)
    F.sort()
    cost = []
    for i in range(len(N)):
        cost.append(A[i]*F[i])

    a = F[cost.index(max(cost))]

    return




def F():
    N, M = LI()

    value = [0] * M
    power = [0] * M
    for i in range(M):
        a, b = LI()
        value[i] = a
        c = LI()
        L = ['0'] * N
        for k in c:
            L[k - 1] = '1'
        bint = ''.join(L)
        power[i] = int(bint, 2)
    bint = ''.join(list(['1'] * N))
    dp = [inf] * (int(bint, 2)+1)
    t = 0
    cost = 0

    dp[0] = 0
    for s in range(int(bint, 2) + 1):
        for i in range(M):
            t = s | power[i]
            cost = dp[s] + value[i]
            dp[t] = min(dp[t], cost)
    print(-1) if(dp[-1] == inf) else print(dp[-1])

    return

    



def solution(S):
    
    N = len(S)

    pass



if __name__ == '__main__':

    A()

Solution (Python):
n = int(input())
s = ['']*n
t = [0]*n
for i in range(0,n):
    s[i],t[i] = input().split()
    t[i] = int(t[i])
x = input()
index = 0
time = 0
for i in range(0,n):
    if x == s[i]:
        index = i
for i in range(index+1,n):
    time += t[i]
print(time)

Solution (Python):
n = int(input())
record = []
for i in range(n):
    pl = list(input().split())
    record.append(pl)
x = input()

isSleep = False
ans = 0

for r in record:
    if isSleep:
        ans += int(r[1])
    if r[0] == x:
        isSleep = True

print(ans)

Solution (Python):


sl = []
nl = []

n = int(input())

for i in range(n):
    s,t= input().split()
    sl.append(s)
    nl.append(int(t))

index = sl.index(input())

cnt = 0

for i in nl[index+1:]:
    cnt += i

print(cnt)

Solution (Python):
n =int(input())
lista = [input().split() for i in range(n)]
x = input()
dicta = dict(lista)
rmnum = lista.index([x,dicta.get(x)])
lista[0:rmnum+1] =[]
ans = 0
for i in range(len(lista)):
    ans+=int(dicta.get(lista[i][0]))
print(ans)

Solution (Python):
N = int(input())

nalist=[]
nblist=[]
for i in range(N):
    na, nb = input().split()
    nalist.append(na)
    nblist.append(int(nb))
X = input()
a=nalist.index(X)
del nblist[0:a+1]
ans=sum(nblist)
print(ans)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    st = input().split()
    s.append(st[0])
    t.append(int(st[1]))
x = input()
check = 0
time = 0

for i in range(n):
    if check == 1:
        time += t[i]
    if s[i] == x:
        check += 1


print(time)

Solution (Python):
n = int(input())
st = [input().split() for _ in range(n)]
x = input()

r = 0
f = False

for s, t in st:
    if f:
        r += int(t)
    if s == x:
        f = True

print(r)

Solution (Python):
n = int(input())
songs = []
for i in range(n):
	songs.append(input().split())
x = input()

for j in range(n):
	if songs[j][0] == x:
		break

answer = 0

for i in range(j+1,n):
	answer += int(songs[i][1])

print(answer)

Solution (Python):
n=int(input())
s_t = []
for i in range(n):
    s_t.append(list(map(str, input().split())))
x = input()

for i,v in enumerate(s_t):
    if v[0] == x:
        sleep_i = i
cnt = 0
for i in s_t[sleep_i+1:]:
    cnt += int(i[1])

print(cnt)

Solution (Python):
n = int(input())
s = []
t = []
for _ in range(n):
    a, b = input().split()
    s.append(a)
    t.append(int(b))
x = input()

ct = 0
for i in range(n):
    if (x == s[n-1 - i]):
        break
    else:
        ct += t[n-1 - i]

print(str(ct))

Solution (Python):
N = int(input())
st= [input().split() for i in range(N)]
s = [k[0] for k in st]
t = [int(k[1]) for k in st]
X = input()

i = s.index(X)
time = sum(t[i+1:])
print(time)

Solution (Python):
n = int(input())

mList = []
for i in range(n):
  mList.append(list(input().split()))

sleepM = input()

sleepIndex = 0
for i in range(n):
  if mList[i][0] == sleepM:
    sleepIndex = i
    break

result = 0
for i in range(sleepIndex+1,n):
  result += int(mList[i][1])

print(result)

Solution (Python):
num_of_songs = int(input())
all_list = [input().split() for _ in range(num_of_songs)]

song_name = input()
ind = 0

for i, tmp_list in enumerate(all_list):
  if tmp_list[0] == song_name:
    ind = i

if ind != len(all_list) - 1:
  print(sum([int(tmp_list[1]) for tmp_list in all_list[ind+1:]]))
else:
  print(0)

Solution (Python):
N = int(input())
song = []
for i in range(N):
    s, t = map(str, input().split())
    song.append([s, int(t)])
X = input()
start = False
sleep = 0
for i in song:
    if start:
        sleep = sleep + i[1]
    if i[0] == X:
        start = True
print(sleep)

Solution (Python):
N = int(input())

playList = []
timeList = []
for cnt in range(N):
    ttl, scd=input().split()
    playList.append(ttl)
    timeList.append(int(scd))

key = input()
index = int(playList.index(key))

print(sum(timeList[index+1: N]))

Solution (Python):
N=int(input())
S=[0]*N
T=[0]*N

for i in range(N):
	S[i],T[i]=input().split()

X=input()

j=S.index(X)
sum=0

for k in range(j+1,N):
	sum+=int(T[k])

print(sum)

Solution (Python):
n = int(input())
li1 = []
li2 = []
for i in range(n):
    a, b = input().split()
    li1.append(a)
    li2.append(int(b))
x = input()

asleep = li1.index(x)
print(sum(li2[asleep+1:]))

Solution (Python):
N = int(input())
list = []
for i in range(N): 
    n = input()    
    m = n.split()
    p = [i for i in m] 
    list.append(p)
x = input()
a = 0
A = 0
for i in list:
    if a == 0:
        if x == i[0]:
            a = 1
        else:
            pass
    else:
        A = A + int(i[1])
print(A)

Solution (Python):
n = int(input())
def f(s):
    list = s.split()
    return list[0],int(list[1])
play = [f(input()) for i in range(n)]
x = input()

s = []
t = []
for i in range(n):
    s.append(play[i][0])
    t.append(play[i][1])

for i in range(n):
    if s[i] == x:
        ans=sum(t[(i+1):(n+1)])

print(ans)

Solution (Python):
class Music:
    def __init__(self, name, time):
        self.name = name
        self.time = int(time)


n = int(input())
data = [(input().split()) for _ in range(n)]
music_list = [Music(d[0], d[1]) for d in data]
x = input()

start_music = None
for music in music_list:
    if music.name == x:
        start_music = music
        break

if start_music is None:
    print(0)
else:
    index = music_list.index(start_music)
    skipped_list = music_list[index+1:]

    skipped_time = 0
    for music in skipped_list:
        skipped_time += music.time
    print(skipped_time)

Solution (Python):
n = int(input())
s = [input().split() for i in range(n)]
x = input()
for i, ti in enumerate(s):
  
  s[i][1] = int(s[i][1])

sum_t = 0
ind = 0


for i, music in enumerate(s):
  
  
  if x in music:
    ind = i
    break



for i, music in enumerate(s):
  if i > ind:
    sum_t += music[1]
print(sum_t)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    input_s, input_t = input().split()
    s.append(input_s)
    t.append(int(input_t))
x = input()
c = 0
for i in range(n):
    if s[i] != x:
        c += 1
    else:
        print(sum(t[c+1:]))

Solution (Python):
N=int(input())
ls1=[]
for _ in range(N):
  title,time=input().split()
  ls1.append([title,int(time)])
X=input()
i=0
a=0
flag=False
while flag==False:
  if ls1[i][0]==X:
    i+=1
    break
  i+=1
while i<N:
  a+=ls1[i][1]
  i+=1
print(a)

Solution (Python):
N = int(input())

P = [input().split() for i in range(N)]
last = input()

sleep_num = 0
sum_time = 0
for i,j in enumerate(P):
  if j[0] == last:
    sleep_num = i
  sum_time += int(j[1])
    


awake = 0
for i,j in enumerate(P):
  awake += int(j[1])
  if i == sleep_num:
    break

k = sum_time - awake

print(k)

Solution (Python):
n = int(input())

name = []
time = []
for _ in range(n):
    tmp = input().split()
    name.append(tmp[0])
    time.append(int(tmp[1]))

s = input()

i = name.index(s) + 1
ans = 0
while i < n:
    ans += time[i]
    i += 1

print(ans)

Solution (Python):
N = int(input())
s,t = list(),list()
for i in range(N):
    S,T = input().split()
    s.append(S)
    t.append(int(T))
index = s.index(str(input()))
print(sum(t[index+1:]))

Solution (Python):
n = int(input())
play_dict = {"_blank": 0}
old_s = "_blank"
for _ in range(n):
  s, t = input().split()
  play_dict[s] = play_dict[old_s] + int(t)
  old_s = s

print(max(play_dict.values()) - play_dict[input()])

Solution (Python):
n = int(input())

s = ['']*n
t = ['']*n
for i in range(n):
    s[i], t[i] = input().split()
    
    
x = input()

p = s.index(x)
total = 0
for i in range(p+1, n):
    total += int(t[i])
print(total)

Solution (Python):
N = int(input())
music =[]
time = []
count=0
for i in range(N):
  s,t = input().split()
  music.append(s)
  time.append(t)
S = input()

n = music.index(S)
for i in range(n+1,N):
  T = int(time[i])
  count +=T

print(count)

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    s_tmp,t_tmp = input().split()
    s.append(s_tmp)
    t.append(int(t_tmp))
x = input()
print(sum(t[s.index(x)+1:]))

Solution (Python):
N = int(input())

P = []

for _ in range(N):
    s,t = input().split()
    t = int(t)
    P.append([s,t])

X = input()

end_index = -1

for i in range(N):
    p = P[i]

    if p[0]==X:
        end_index = i
        break

count = 0

for i in range(end_index+1, N, 1):
    count = count + P[i][1]
print(count)

Solution (Python):
n = int(input())
slist = []
tlist = []
dist = {}
sumt = 0
for i in range(n):
    s,t = input().split()
    t = int(t)
    slist.append(s)
    tlist.append(t)
for i in range(n):
      sumt += tlist[i]
for i in range(n):
  
    if i+1 <n:
      
      tlist[i+1] += tlist[i]  

        
    
    dist[slist[i]] = tlist[i]
x = input()
ans = sumt - dist[x] 
print(ans)

Solution (Python):
n = int(input())
s_list = []
t_list = []
for _ in range(n):
  s, t = input().split()
  s_list.append(s)
  t_list.append(int(t))
print(sum(t_list[s_list.index(input())+1:]))

Solution (Python):
n = int(input())
title_list = []
time_list = []
for i in range(n):
    title,time = input().split(" ")
    time = int(time)
    title_list.append(title)
    time_list.append(time)

x = input()

total = 0
for i,j in enumerate(title_list):
    total += time_list[i]
  
time_res = 0
for i,j in enumerate(title_list):
    if j != x:
        time_res += time_list[i]
    else:
        time_res += time_list[i]
        break


        
print(total - time_res)

Solution (Python):
N = int(input())
s, t = [], []
for i in range(N):
    s_i, t_i = input().split()
    s.append(s_i)
    t.append(int(t_i))
X = input()

flag = False
ans = 0

for s_i, t_i in zip(s, t):
    if flag:
        ans += t_i
    if s_i == X:
        flag = True

print(ans)

Solution (Python):
n = int(input())
arr = []
[arr.append(input().split(' ')) for _ in range(n)]

search = input()
ans = 0
flag = False
for i in range(n):
  if flag:
    ans += int(arr[i][1])
  if search == arr[i][0]:
    flag = True

    
print(ans)

Solution (Python):
n = int(input())
sl = []
tl = []
cn = 0
tnp = 0

for i in range(n):
    s, t = map(str, input().split())
    t = int(t)
    sl.append(s)
    tl.append(t)

x = str(input())

for j in range(n):
    if sl[j] == x:
        cn = j

print(sum(tl) - sum(tl[:cn+1]))

Solution (Python):
n = int(input())
s = [0] * n
t = [0] * n
for i in range(n):
    s[i],t[i] = map(str,input().split())
x = str(input())

counter = 0
switch = 0
for i in range(n):
    if switch == 1:
        counter += int(t[i])
    if s[i] == x:
        switch = 1

print(counter)

Solution (Python):
n=int(input())
_dict = []
for i in range(n):
    _dict.append(list(map(str, input().split())))
end_music = input()
for i in range(n):
    _dict[i][1]=int(_dict[i][1])


ans=0
start=False
for i in range(n):
    if start==True:
        ans+=_dict[i][1]
    if _dict[i][0]==end_music:
        start=True
print(ans)

Solution (Python):
ans = 0
flag = 0
N = int(input())
a = []
b = []

for i in range(N):
    c,d = input().split()
    a.append(c)
    b.append(d)

e = input()

for i in range(N):
    if a[i] == e:
        flag = 1
        continue
    if flag == 1:
        ans += int(b[i])

print(ans)

Solution (Python):
n = int(input())
s = []
for _ in range(n):
    s.append(input().split())
x = input()

m_l = []
for i in s:
    m_l.append(i[0])

t = []
for j in s:
    t.append(int(j[1]))

m_s = n - m_l.index(x) - 1

ans = 0

for r in range(m_l.index(x)+1,n):
    ans += t[r]
print(ans)

Solution (Python):
n = int(input())
s,t  = ["a"]*n,["0"]*n
for i in range(n):
    s[i],t[i] = input().split()
x = str(input())

r = [0]

for i in range(len(s)):
    r.append(int(t[i]) + r[i])

for i in range(len(s)):
    if(s[i] == x):
        v = i+1
        break
print(r[len(r)-1] - r[v])

Solution (Python):


def main():
	numOfSongs = int(input())
	songList = [input().split() for i in range(numOfSongs)]
	asleepSong = input()
	index = search(songList, asleepSong)[0]
	seconds = sumSeconds(songList[(index+1):])
	print(seconds)
	

def search(list, value):
	return [i for i, x in enumerate(list) if x[0] == value]

def sumSeconds(lst):
	sum = 0
	for s in lst:
		sum += int(s[1])
	return sum

main()

Solution (Python):
import sys

read = sys.stdin.read

N, *st, X = map(str, read().split())
flag = False
answer = 0

for s, t in zip(*[iter(st)] * 2):
    if flag:
        answer += int(t)
    if s == X:
        flag = True

print(answer)

Solution (Python):
N = int(input())
s = []
t = []
for i in range(N):
    sp, tp = input().split(" ")
    s.append(sp)
    t.append(int(tp))

X = input()

cnt = 0
ans = 0

for i in range(N):
    if cnt == 1:
        ans += t[i]
    if s[i] == X:
        cnt = 1

print(ans)

Solution (Python):
N = int(input())

s_list =[]
t_list = []
for i in range(N):
	s,t = map(str, input().split())
	s_list.append(s)
	t_list.append(int(t))

X = input()    
    
print(sum(t_list[s_list.index(X)+1:]))

Solution (Python):
n = int(input())
sList = []
tLsit = []
result = 0
count = 0
Bool = False
for _ in range(n) :
    s, t = map(str, input().split())
    sList += [s]
    tLsit += [int(t)]
x = input()

for S in sList :
    if Bool :
        result += tLsit[count]
    if S == x :
        Bool = True
    count += 1

print(result)

Solution (Python):
N =int(input())
kyoku = [list(input().split()) for _ in range(N)]
X = input()
num = 0
for i in range(N):
    if kyoku[i][0] == X:
        num = i
print(sum(list([ int(i[1]) for i in kyoku[(num+1):] ])))

Solution (Python):
N = int(input())
S = []
T = []
answer = 0
START = 0

for i in range(N):
    s,t = input().split()
    t = int(t)
    S.append(s)
    T.append(t)
X = input()

for i in range(N):
    if X == S[i]:
        START = i

for i in range(START+1,N):
    answer = answer + T[i]
print(answer)

Solution (Python):
n = int(input())
songs = [
    input().split() for i in range(n)
]
x = input()

ans = 0
asleep = 0
for i in range(n):
    if songs[i][0] == x:
        asleep = 1
    elif asleep:
        ans += int(songs[i][1])
    else:
        continue
print(ans)

Solution (Python):
N = int(input())
s=[]
t=[]
for i in range(N):
    x,y=map(str,input().split())
    s.append(x)
    t.append(y)

X=input()
k=0
for i,j in enumerate(s):
    if j==X:
        k=i
        break
d=0
for i in range(k+1,N):
    d+=int(t[i])
print(d)

Solution (Python):
N = int(input())
S = []
for i in range (N):
	title,time=input().split()
	S.append((title,time,i))
X = input()
ans = 0

for i in S:
	if i[0] == X:
		tmp = i[2]
		break
for i in S:
	if i[2]>tmp:
		ans =ans+int(i[1])

print(ans)

Solution (Python):
n = int(input())
S = []
T = []
for _ in range(n):
    s,t = map(str, input().split())
    S.append(s)
    T.append(int(t))

x = input()

for i, s in enumerate(S):
    if s == x:
        ans = sum(T[i+1:])
        break

print(ans)

Solution (Python):
n = int(input())
st = []
for _ in range(n):
    s = list(map(str, input().split()))
    s[1] = int(s[1])
    st.append(s)
x = input()

st = reversed(st)

sum = 0
for kyoku in st:
    if kyoku[0]  == x:
        break
    else:
        sum += kyoku[1]

print(sum)

Solution (Python):
n=int(input())
s=[]
t=[]
for i in range(n):
    a,b=map(str,input().split())
    s.append(a)
    t.append(int(b))
sum_t=sum(t)
x=input()
idx=0
awake=0
for i in range(n):
    if s[i]!=x:
        awake+=t[i]
    else:
        awake+=t[i]
        break
print(sum_t-awake)

Solution (Python):
n=int(input())
p=[]
for i in range(n):
    s,t=input().split()
    p.append([s,int(t)])
p.append(["eol", 0])
x=input()
su=0
for i in p:
    su+=i[1]
sud=0
c=0
for i in p:
    sud+=p[c][1]
    if p[c][0]==x:
        break
    c+=1
print(su-sud)

Solution (Python):

N = int(input())
s = list(input().split() for i in range(N))
X = str(input())
ans = 0


count = 0
for i in range(N):
    if str(s[i][0]) == X:
        break
    else:
        count += 1



for j in range(count+1,N):
    ans += int(s[j][1])

print(ans)

Solution (Python):
N = int(input())
songs = []
times = []
ans = 0
for _ in range(N):

    name, time = input().split(" ")
    songs.append(name)
    times.append(int(time))

X = input()

index = songs.index(X)
ans = sum(times[index+1:])
print(ans)

Solution (Python):

N = int(input())
H=[]
for i in range(N):
    H.append(input().split())
X = str(input())
for i in range(N):
    if X==str(H[i][0]):
        k=i
        break
ans=0
for i in range(k+1,N):
    ans+=int(H[i][1])
print(ans)

Solution (Python):
n = int(input())
songList = [0] * n
timeList = [0] * n
for i in range(n):
    songList[i], timeList[i] = input().split()
x = input()

timeList = [int(time) for time in timeList]

sleepIndex = -1
for i, song in enumerate(songList):
  if song == x:
    sleepIndex = i
    break

print(sum(timeList[i+1:]))

Solution (Python):
N = int(input())
st = []
st.append([list(map(str, input().split())) for _ in range(N)])
X = str(input())
ans = 0

for i in range(N):
  st[0][i][1] = int(st[0][i][1])
  
flag = 0

for i in range(N):
  if flag == 0:
    if st[0][i][0] == X:
      flag = 1
  else:
    ans += st[0][i][1]
    
print(ans)

Solution (Python):
from collections import OrderedDict as od

m1 = od()

n=int(input())

for i in range(n):
	l=input().split()
	s=l[0];t=int(l[1])
	m1[l[0]]=t

x=input()
flag=0;total=0
for key,value in m1.items():
	if key == x:
		flag=1
		continue
	if flag==1:
		total+=value

print(total)

Solution (Python):
import numpy as np

N = int(input())
st = np.array([list(input().split()) for _ in range(N)])
X = input()

s = list(st[:, 0])
t = list(map(int, st[:, 1]))
index = s.index(X)
print(sum(t[index+1:]))

Solution (Python):
N = int(input())
S = []
T = []
for i in range(N):
  s, t = input().split()
  S.append(s)
  T.append(int(t))
X = input()

if S.index(X) == 0:
  time = sum(T) - T[S.index(X)]
else:
  time = sum(T[S.index(X) + 1:])

print(time)

Solution (Python):
n = int(input())
inlist=[]
for j in range(n):
  s, i = input().split()
  inlist.append(s+"."+i)
x = input()


result = 0
flag = False
for j in inlist:
  smoji,number = j.split(".")
  if flag:
    result += int(number)
  if smoji == x:
    flag = True

print(result)

Solution (Python):
N = int(input())
L = [0] * N
M = [0] * N
for i in range(N):
    L[i], M[i] = map(str, input().split())
K = [int(s) for s in M]
X = str(input())
t = L.index(X)
count = 0
for i in range(t + 1, N):
    count += K[i]
print(count)

Solution (Python):
n = int(input())
list = []
for i in range(n):
  s,t = input().split()
  list.append((s, int(t)))
x = input()
flag = False
time = 0
i = 0

while i < n:
  if list[i][0] == x:
    flag = True
    time = time - list[i][1]
  if flag == True:
    time = time + list[i][1]
  i = i + 1
print(time)

Solution (Python):
n = int(input())

s = []
t = []

sum = 0

for i in range(n):
    a,b = input().split()
    s.append(a)
    t.append(b)
x = input()

for i in range(n):
    if x == s[i]:
        for j in range(i+1,n):
            sum += int(t[j])
        break

print(sum)

Solution (Python):
N=int(input())
s=[]
t=[]
j=0
k=0
for i in range(N):
 a,b= input().split()
 s.append(a)
 t.append(int(b))
o=input()
for i in range(N):
 if j==1:
  k+=t[i]
 if s[i]==o:
  j+=1
print(k)

Solution (Python):
n=int(input())
s=[]
t=[]
u=[]
for i in range(n):
    s_i,t_i=input().split()
    s.append(s_i)
    t.append(int(t_i))
x=input()
for i in range(n):
    if s[i]!=x:
        u.append(t[i])
    else:
        u.append(t[i])
        ans=sum(t)-sum(u)
        break
print(ans)

Solution (Python):
n = int(input())
playlist = []
seccond = []

i = 0
while i < n:
    name, sec = input().split()
    playlist.append(name)
    seccond.append(int(sec))

    i += 1

x = input()
si = playlist.index(x)+1
cnt = 0

while si < n:
    cnt += seccond[si]

    si += 1


print(cnt)

Solution (Python):
N = int( input() )
p = {}
lengh = []
for i in range(N):
    s,t = map(str,input().split())
    t = int(t)
    p[s] = i
    lengh.append(t)

ans = p[input("")]
print(sum(lengh[ans:]) - lengh[ans])

Solution (Python):
n = int(input())
playlist = []
for i in range(n):
    playlist.append(input().split())
x = input()

start = 0
ans = 0
for i in range(n):
  if playlist[i][0] == x:
    start = i+1
for i in range(start,n):
  ans += int(playlist[i][1])
print(ans)

Solution (Python):
n = int(input())
sl, tl = [], []
for _ in range(n):
    s, t = input().split()
    sl.append(s)
    tl.append(int(t))
x = input()

i = sl.index(x) + 1
print(sum(tl[i:]))

Solution (Python):
N=int(input())
slist=[input().split() for i in range(N)]
X=input()
sumT=0
flag=0
for j in range(len(slist)):
  if flag==1:
    sumT+=int(slist[j][1])
  if slist[j][0]==X:
    flag=1
print(sumT)

Solution (Python):
N = int(input())
s,t = list(),list()
for i in range(N):
    S,T = input().split()
    s.append(S)
    t.append(int(T))
index = s.index(str(input()))
print(sum(t[index+1:]))

Solution (Python):
n = int(input())
s = []
t = []
for i in range(n):
    temp1,temp2 = input().split()
    s.append(temp1)
    t.append(int(temp2))

x = input()
sum = 0
for i in range(s.index(x)+1,n):
    sum +=t[i]

print(sum)

Solution (Python):
import itertools
from fractions import gcd

def main():
    N = int(input())
    a = [list(map(str, input().split())) for i in range(N)]
    song = input()
        
    count = 0
    for i in range(N-1,0,-1):
        if a[i][0] == song:
            print(count)
            return
        else:
            count+= int(a[i][1])
    print(count)
main()