303755: CF725A. Jumping Ball

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Jumping Ball

题意翻译

- 在Pinball 游戏里面,保险杠是赛场的一个重要部分。 - 保险杠有两种类型:`<` 或 `>`。 - 球从起始位置开始,碰到保险杠时,如果保险杠是 `>`,那么球右移一格,反之左移一格。 - 当球落出场外( 球的位置 $\lt 1$ 或 $\gt n$ )时,结束游戏。 - 球可能一直在场上,也可以最后掉出场外。 **输入:** - 第一行一个正整数 $n$ ( $1 \leq n \leq 2000000$ ),表示保险杠的个数。 - 第二行一个含有 $n$ 个字符的字符串,该字符串只含有 `<` 或 `>`,表示保险杠的类型。 请输出可以让球最终落出场外的起始位置的个数。

题目描述

In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of $ n $ bumpers. The bumpers are numbered with integers from $ 1 $ to $ n $ from left to right. There are two types of bumpers. They are denoted by the characters '<' and '>'. When the ball hits the bumper at position $ i $ it goes one position to the right (to the position $ i+1 $ ) if the type of this bumper is '>', or one position to the left (to $ i-1 $ ) if the type of the bumper at position $ i $ is '<'. If there is no such position, in other words if $ i-1&lt;1 $ or $ i+1&gt;n $ , the ball falls from the game field. Depending on the ball's starting position, the ball may eventually fall from the game field or it may stay there forever. You are given a string representing the bumpers' types. Calculate the number of positions such that the ball will eventually fall from the game field if it starts at that position.

输入输出格式

输入格式


The first line of the input contains a single integer $ n $ ( $ 1<=n<=200000 $ ) — the length of the sequence of bumpers. The second line contains the string, which consists of the characters '<' and '>'. The character at the $ i $ -th position of this string corresponds to the type of the $ i $ -th bumper.

输出格式


Print one integer — the number of positions in the sequence such that the ball will eventually fall from the game field if it starts at that position.

输入输出样例

输入样例 #1

4
<<><

输出样例 #1

2

输入样例 #2

5
>>>>>

输出样例 #2

5

输入样例 #3

4
>><<

输出样例 #3

0

说明

In the first sample, the ball will fall from the field if starts at position $ 1 $ or position $ 2 $ . In the second sample, any starting position will result in the ball falling from the field.

Input

题意翻译

- 在Pinball 游戏里面,保险杠是赛场的一个重要部分。 - 保险杠有两种类型:`<` 或 `>`。 - 球从起始位置开始,碰到保险杠时,如果保险杠是 `>`,那么球右移一格,反之左移一格。 - 当球落出场外( 球的位置 $\lt 1$ 或 $\gt n$ )时,结束游戏。 - 球可能一直在场上,也可以最后掉出场外。 **输入:** - 第一行一个正整数 $n$ ( $1 \leq n \leq 2000000$ ),表示保险杠的个数。 - 第二行一个含有 $n$ 个字符的字符串,该字符串只含有 `<` 或 `>`,表示保险杠的类型。 请输出可以让球最终落出场外的起始位置的个数。

加入题单

算法标签: