Minuses

No attempts yetTime limit1sMemory limit128 MB

Problem

Subtraction is not associative. For example (52)1=2(5-2)-1=2 but 5(21)=45-(2-1)=4, so (52)15(21)(5-2)-1 \ne 5-(2-1). This means the value of an expression such as 5215-2-1 depends on the order in which the subtractions are performed. When there are no brackets we agree to evaluate from left to right, so 5215-2-1 means (52)1(5-2)-1.

You are given an expression of the form x1±x2±±xn,x_1 \pm x_2 \pm \dots \pm x_n, where each ±\pm is either ++ or -, and x1,x2,,xnx_1, x_2, \dots, x_n are pairwise distinct variables.

We want to insert brackets into the all-minus expression x1x2xnx_1 - x_2 - \dots - x_n so that it becomes equivalent to the given expression (the two expressions are equal for every value of the variables). At most n1n-1 pairs of brackets may be inserted, and no pair of brackets may enclose zero or one variable.

For example, to match x1x2x3+x4+x5x6+x7x_1 - x_2 - x_3 + x_4 + x_5 - x_6 + x_7 we may bracket x1x2x3x4x5x6x7x_1 - x_2 - x_3 - x_4 - x_5 - x_6 - x_7 as ((x1x2)(x3x4x5))(x6x7).((x_1-x_2)-(x_3-x_4-x_5))-(x_6-x_7). This is only one of many possible bracketings, and it is not necessarily one that uses the fewest pairs. Determine the minimum number of bracket pairs over all valid bracketings.

Input

The first line contains an integer nn (2n1062 \le n \le 10^6), the number of variables in the given expression. Each of the next n1n-1 lines contains a single character, ++ or -. The kk-th of these lines (1kn11 \le k \le n-1) is the sign between xkx_k and xk+1x_{k+1} in the given expression. You may assume that a valid bracketing always exists for the input.

Output

Print a single integer: the minimum number of bracket pairs that must be inserted into x1x2xnx_1 - x_2 - \dots - x_n to obtain an expression equivalent to the given one.