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 in JavaScript (node.js v5.12) (judge verdict: Accepted)

/// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
    ninput = input[0].split(" ");
   
    var n = parseInt(ninput[0], 10);
    var ss = [];var tt = [];
    
    for (var f = 1; f <= n; f++) {
         sinput = input[f].split(" ");
    //  sinput = input[f].trim().split(" ");
    
          var s= sinput[0];
          var t= parseInt(sinput[1],10);
     //   console.log(s);
               ss[f-1] = s;
   //    console.log(ss);
               tt[f-1] = t;
        }
     //     console.log(ss);
      //    console.log(tt);
   
          var x =input[f];
      //    console.log(x);
       //  var ttt = tt[0]+tt[1]+tt[2];
  //console.log(ttt);

 
 
//配列内に「イチゴ」が存在するかを検索する
var cnt = ss.indexOf( x );
 
//console.log( cnt );
var r =0;
for(p = cnt+1;p<n;p++){r = r + tt[p];
          //   console.log(r);
            }
 
    console.log(r)
  
   
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));