Dancing school#160

Dancing school

1 segundo
128 megabytes
Media (≈1350)

Professor Arkan's ballroom dance school has enrolled students—boys and girls. The professor lines them up in a single row and wants to select a group of consecutive students for the first lesson such that the number of boys and girls in the group is equal. How many ways can the professor choose such a group?

Entrada

The first line contains an integer (1 \leq n \leq 10^6). The second line contains a string of characters, each either (representing a girl) or (representing a boy).

Salida

Print a single integer—the number of ways to choose a group in which the number of boys and girls is equal.

Ejemplos

Ejemplo 1

Loading
Loading