QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100

#17802. Line of Pac-Man

统计

"Wow! Why are Pac-Men crawling out of my bento box!"

Kruskal-chan looked in horror at the sandwich in her hand, where the dense sesame seeds had suddenly turned into countless tiny Pac-Men, moving frantically left and right! Even more bizarrely, bean-shaped light spots appeared in the air, being devoured by them one by one.

"Is this the truth of the universe?" Kruskal-chan tremblingly took out her notebook, deciding to calculate the minimum number of beans that would be eaten...

Some beans and Pac-Men are distributed on the integer points of the line segment $1 \le x \le n$. There are two types of Pac-Men: one moving to the left at unit speed, and one moving to the right at unit speed. When a Pac-Man passes a bean, the bean is eaten. When two Pac-Men meet, you must choose one of them to eat the other, and the remaining Pac-Man continues to move in its original direction.

Find the minimum total number of beans that will be eaten.

Note: The positions of the Pac-Men can change continuously, not discretely.

Input

This problem contains multiple test cases.

The first line contains an integer $T$ ($1 \le T \le 10^5$), representing the number of test cases.

Each test case starts with a line containing an integer $n$ ($1 \le n \le 10^5$), representing the right endpoint of the line segment.

The next line contains a string of length $n$. The string contains only the four characters ., o, <, >, representing an empty space, a bean, a Pac-Man moving left, and a Pac-Man moving right, respectively.

It is guaranteed that $\sum n \le 10^5$.

Output

Output $T$ lines, each containing an integer representing the minimum total number of beans eaten.

Examples

Input 1

2
6
o>.<oo
2
<>

Output 1

1
0

Note

In the first example, when the two Pac-Men meet, choosing to keep the one moving to the left results in only the leftmost bean being eaten, so the answer is 1.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.