  N = gets.to_i
  s = Array.new(N)
  t = Array.new(N)
  N.times do |i|
    s[i],t[i]=gets.chomp.split
  end

  X = gets.chomp

  sw="off"
  ans=0
  N.times do |i|
    if sw=="on"
      ans = ans+t[i].to_i
    elsif s[i]==X
      sw="on"
    end
  end

  puts ans