output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      s_1 t_1
      \vdots
      s_{N} t_N
      X
attempt: import sys
  
  s2nn = lambda s: [int(c) for c in s.split(" ")]
  ss2nn = lambda ss: [int(s) for s in list(ss)]
  ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
  i2s = lambda: sys.stdin.readline().rstrip()
  i2n = lambda: int(i2s())
  i2nn = lambda: s2nn(i2s())
  ii2ss = lambda n: [i2s() for _ in range(n)]
  ii2nn = lambda n: ss2nn(ii2ss(n))
  ii2nnn = lambda n: ss2nnn(ii2ss(n))
  
  s2ss = lambda s: [int(c) for c in s.split(" ")]
  
  
  def main():
      N = i2n()
      t_total = 0
      d = {}
      for _ in range(N):
          s, t = sys.stdin.readline().rstrip().split(" ")
          t_total += int(t)
          d[s] = t_total
      X = i2s()
      print(t_total - d[X])
  
  
  main()
  
problem_description: 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.
samples: [{"input": "3\n    dwango 2\n    sixth 5\n    prelims 25\n    dwango", "output": "30\n    \n\n  * While Niwango was asleep, two songs were played: `sixth` and `prelims`.\n  * The answer is the total duration of these songs, 30.\n\n* * *"}, {"input": "1\n    abcde 1000\n    abcde", "output": "0\n    \n\n  * No songs were played while Niwango was asleep.\n  * In such a case, the total duration of songs is 0.\n\n* * *"}, {"input": "15\n    ypnxn 279\n    kgjgwx 464\n    qquhuwq 327\n    rxing 549\n    pmuduhznoaqu 832\n    dagktgdarveusju 595\n    wunfagppcoi 200\n    dhavrncwfw 720\n    jpcmigg 658\n    wrczqxycivdqn 639\n    mcmkkbnjfeod 992\n    htqvkgkbhtytsz 130\n    twflegsjz 467\n    dswxxrxuzzfhkp 989\n    szfwtzfpnscgue 958\n    pmuduhznoaqu", "output": "6348"}]