atcoder#AGC040A. [AGC040A] ><

[AGC040A] ><

Score : 300300 points

Problem Statement

Given is a string SS of length N1N-1. Each character in SS is < or >.

A sequence of NN non-negative integers, a1,a2,,aNa_1,a_2,\cdots,a_N, is said to be good when the following condition is satisfied for all ii (1iN11 \leq i \leq N-1):

  • If Si=S_i= <: $a_i
  • If Si=S_i= >: ai>ai+1a_i>a_{i+1}

Find the minimum possible sum of the elements of a good sequence of NN non-negative integers.

Constraints

  • 2N5×1052 \leq N \leq 5 \times 10^5
  • SS is a string of length N1N-1 consisting of < and >.

Input

Input is given from Standard Input in the following format:

SS

Output

Find the minimum possible sum of the elements of a good sequence of NN non-negative integers.

<>>
3

a=(0,2,1,0)a=(0,2,1,0) is a good sequence whose sum is 33. There is no good sequence whose sum is less than 33.

<>>><<><<<<<>>><
28