ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1135. Recruits

Time limit: 1.0 second
Memory limit: 64 MB
N recruits are standing in front of a sergeant who orders to turn left. Some of the soldiers turn left, while the others turn right. In a second each recruit seeing the face of another recruit understands that a mistake was made and turns around. This happens at the same time to each pair of soldiers facing each other. The process continues until the formation becomes stable. Write a program, which finds out the number of times when a pair of soldiers turned around. If the process is infinite then the program should write the word “NO”.
Example:
Legend:
‘<’: a recruit facing left;
‘>’: a recruit facing right.
Formation Comments Number of turns
> > < < > < Initial formation 2
> < > < < > One second has passed 2
< > < > < > Two seconds have passed 2
< < > < > > Three seconds have passed 1
< < < > > > Final formation Total: 7

Input

The first line contains the number of recruits (N). The rest of the input contains only ‘<’, ‘>’ and line break characters. There is exactly N ‘<’ and ‘>’ characters in the input. Each line of the input may have up to 255 characters.
1 ≤ N ≤ 30000.

Output

Write the number of turns.

Sample

inputoutput
6
>><<><
7
Problem Source: Quarterfinal, Central region of Russia, Rybinsk, October 17-18 2001