11391139 SUSTech Online Judge
Problem 1139 --HuaXin BookStore[Easy]

1139: HuaXin BookStore[Easy]

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 825  Solved: 221
[Submit][Status][Web Board]

Description

HuaXin bookstore is  not a famous bookstore. However, it still attracts many people to go there every day. Now, there are several kinds of books in HuaXin bookstore. Each kind of books has an amount of ai (1 <= ai  <= 20). People comes to HuaXin bookstore to find the book  which he/she wants to read. But after  statistics, the boss found that some customers may leave without having a look of the book if there is no book available.In addition, the customers who enters with no book to read will only hang in the bookstore without looking any book before he leave. Your task is to write a program to tell the boss how many customers left without having a look of the books. 

Input

The input consists of data for one or more kinds of books, followed by a line containing the number 0 that signals the end of the input. Data for each kind of book is a single line containing a positive integer, representing the amount of this kind of book, followed by a space, followed by a sequence of uppercase letters. Letters in the sequence occur in pairs. The first occurrence indicates the arrival of a customer, the second indicates the departure of that same customer. No letter will occur in more than one pair. 

Output

For each kind of book, output the number of customers walked away.

Sample Input

2 CBBCJJKZKZ
3 GAKKBDDBAGNN
3 NACCQNDDQAEE
0

Sample Output

0
1
0

HINT

Source

 

[Submit][Status]