401915: GYM100574 B Valentine's Restaurant
Description
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 .
InputA proper sequence of [ and ], s .
1 ≤ |s| ≤ 1000
OutputAn integer.
ExamplesInput[][[[]][][][][[]]][]Output
3Input
[[]][][[[[[]]]]][[][][]][[][][]]Output
5Input
[]Output
1