401915: GYM100574 B Valentine's Restaurant

Memory Limit:64 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Valentine's Restauranttime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output

Peyman wants to take his love, Kimia to a modern restaurant, MaInHameRahUmadim on Valentine's day. The are n tables there. Each table has some subtables. Their graph forms a rooted forest (each component forms a rooted tree). Kimia just wondered, what's the number of connected components in this graph ? Peyman is lazy and also he wants everything to be perfect. So he asked you to answer him.

As you know, we can show a rooted forest with a proper sequence of [ and ]. Here, each vertex has an interval (a [ and its match) and a vertex is an ancestor of another vertex, if the other vertex's interval is inside it's interval.

You are given this forest as a string with [ and ] . You should write a program using Prolan language that it's input is the forest, and it's output is the number of components (an integers), without leading zero .

Your program's order mustn't exceed 107 .

Input

A proper sequence of [ and ], s .

1 ≤ |s| ≤ 1000

Output

An integer.

ExamplesInput
[][[[]][][][][[]]][]
Output
3
Input
[[]][][[[[[]]]]][[][][]][[][][]]
Output
5
Input
[]
Output
1

加入题单

算法标签: