Problem:
 Score : 300 points    Problem Statement Given is a string S of length N-1 .
Each character in S is < or > .  A sequence of N non-negative integers, a_1,a_2,\cdots,a_N , is said to be good when the following condition is satisfied for all i ( 1 \leq i \leq N-1 ):   If S_i=  < : a_i<a_{i+1}  If S_i=  > : a_i>a_{i+1}   Find the minimum possible sum of the elements of a good sequence of N non-negative integers.      Constraints  2 \leq N \leq 5 \times 10^5  S is a string of length N-1 consisting of < and > .         Input Input is given from Standard Input in the following format:  S       Output Find the minimum possible sum of the elements of a good sequence of N non-negative integers.        Sample Input 1 <>>      Sample Output 1 3  a=(0,2,1,0) is a good sequence whose sum is 3 .
There is no good sequence whose sum is less than 3 .       Sample Input 2 <>>><<><<<<<>>><      Sample Output 2 28

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np

s = input()[:-1]

cnts = []

tmp = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        tmp += 1
    else:
        if s[i] == '>':
            tmp *= -1
        cnts.append(tmp)
        tmp = 1

if s[-1] == '>':
    tmp *= -1
cnts.append(tmp)

idx = 0
a = [0] * (len(s)+1)

for i in range(len(cnts)):
    if i != 0 and cnts[i-1] > 0 and cnts[i] < 0 and a[idx-1] >=  abs(cnts[i]):
        a[idx] = a[idx-1] + 1

    for j in range(abs(cnts[i])):
        if a[idx] != 0:
            idx += 1
            continue
        if cnts[i] > 0:
            a[idx] = j
        else:
            a[idx] = abs(cnts[i]) - j
        idx += 1
if s[-1] == '<':
    a[-1] = a[-2] + 1



print(sum(a))

Solution (Python):
s=str(input())
sl=len(s)+1
l,r=[0]*sl,[0]*sl
ss=[0]*sl
lcnt,rcnt=0,0
for i in range(sl):
  if i==0:
    l[0]=0
    r[sl-1]=0
  else:
    if s[i-1]=="<":
      lcnt+=1
    else:
      lcnt=0
    if s[sl-i-1]==">":
      rcnt+=1
    else:
      rcnt=0
    l[i]=lcnt
    r[sl-i-1]=rcnt
for i in range(sl):
  ss[i]=max(l[i],r[i])
print(sum(ss))

Solution (Python):
def left(arr, idx):
    if L[idx] != None:
        return L[idx]

    if arr[idx] == '<':
        if idx == 0:
            ret = 1
        else:
            ret = left(arr, idx-1) + 1
    else:
        ret = 0

    L[idx] = ret
    return ret
        
def right(arr, idx):
    if R[idx] != None:
        return R[idx]

    if arr[idx] == '>':    
        if idx == len(arr)-1:
            ret =  1
        else:
            ret = right(arr, idx+1) + 1
    else:
        ret = 0
    R[idx] = ret
    return ret

def main():
    S = list(input())
    N = len(S)
    A = [0 for _ in range(N+1)]
    
    global L; L = [None for _ in range(N)]
    global R; R = [None for _ in range(N)]

    for i in range(N):
        j = N - i - 1
        L[i] = left(S, i)
        R[j] = right(S, j)
    
    L = [0] + L
    R = R + [0]

    for i in range(len(A)):
        A[i] = max(L[i], R[i])
            
    print(sum(A))

if __name__ == "__main__":
    main()

Solution (Python):
S = list(input())
l = [0]*(len(S) + 1)
for i in range(len(S)):
  if S[i] == "<":
    l[i + 1] = l[i] + 1
for i in range(len(S)):
  if S[-i - 1] == ">" and l[-i - 2] <= l[-i -1]:
    l[-i -2] = l[-i - 1] + 1
print(sum(l))

Solution (Python):
S = input()

chasms = []
for i in range(len(S) - 1):
    if S[i] + S[i + 1] == "><":
        chasms.append(i + 1)

blocks = []
if len(chasms) == 0:
    blocks.append(S)
else:
    blocks.append(S[:chasms[0]])
    for i in range(len(chasms) - 1):
        blocks.append(S[chasms[i]:chasms[i + 1]])
    blocks.append(S[chasms[-1]:])

answer = 0
for i in blocks:
    a = i.count("<")
    b = i.count(">")
    if a >= b:
        n = a
        m = b - 1
    else:
        n = b
        m = a - 1
    answer += n * (n + 1) // 2
    answer += m * (m + 1) // 2

print(answer)

Solution (Python):
S = input()
if S[0] != '<':
    S = '<' + S
if S[-1] != '>':
    S = S + '>'

N = len(S)
ls = [[],[0]]
for i in range(N-1):
    if S[i] == '<' and S[i+1] == '>':
        ls[0].append(i+1)
    if S[i] == '>' and S[i+1] == '<':
        ls[1].append(i+1)
ls[1].append(N)
M = len(ls[0])
ans = 0
for i in range(M):
    s,t = max(ls[0][i]-ls[1][i], ls[1][i+1]-ls[0][i]),min(ls[0][i]-ls[1][i], ls[1][i+1]-ls[0][i])
    ans += s*(s+1) //2 + (t-1)*(t) //2

print(ans)

Solution (Python):
S=input()
N=len(S)+1
S='>'+S+'<'
a=[0] * (N+2)

i=1
while i<=N:
    if S[i-1]==">" and S[i]=="<":
        a[i]=0

        j=i
        while j>=1:
            if S[j-1]==">":
                if a[j-1]<=a[j]:
                    a[j-1]=a[j]+1
                j=j-1
            else:
                break

        k=i
        while k<=N:
            if S[k]=="<":
                if a[k+1]<=a[k]:
                    a[k+1]=a[k]+1
                k=k+1
            else:
                break
    i=i+1

a[0]=0
a[N+1]=0
print(sum(a))

Solution (Python):
s=input()
list=[0 for _ in range(len(s) + 1)]

for n in range(0, len(s), 1):
    if '<' == s[n] and list[n] >= list[n + 1]:
        list[n + 1] += list[n] - list[n + 1] + 1

for n in range(len(s) - 1, -1, -1):
    if '>' == s[n] and list[n] <= list[n + 1]:
        list[n] += list[n + 1] - list[n] + 1

print(sum(list))

Solution (Python):
s = input()
buf = 0
str_len = len(s)
total = 0

while buf < str_len:
    l_count = 0
    r_count = 0

    while buf < str_len and s[buf] == "<":
        l_count += 1
        buf += 1

    while buf < str_len and s[buf] == ">":
        r_count += 1
        buf += 1

    f = lambda x : x * ( x + 1 ) // 2
    n = max(l_count, r_count)
    total += f(n)
    m = min(l_count, r_count) - 1
    total += f(m)

print(total)

Solution (Python):
s = input()

res = 0
i = 0
while (i < len(s)):
    a, b = 0, 0
    while (i < len(s) and s[i] == '<'):
        i += 1
        a += 1
    while (i < len(s) and s[i] == '>'):
        i += 1
        b += 1
    c = min(a, b)
    d = max(a, b)
    res += (c * (c - 1)) // 2
    res += (d * (d + 1)) // 2

print(res)

Solution (Python):
S = input()
snum = len(S)
N = snum +1
Nar = [0 for i in range(N)]

for i in range(snum):
    if S[i] == '<':
        Nar[i+1] = Nar[i] + 1

for i in reversed(range(N-1)):
    if S[i] == '>':
        Nar[i] = max(Nar[i],Nar[i+1]+1)
sum = 0
for i in Nar:
    sum += i
print(sum)

Solution (Python):
S=input()
N=len(S)+1
S='>'+S+'<'
a=[0] * (N+2)

i=1
while i<=N:
    if S[i-1]==">" and S[i]=="<":
        a[i]=0

        j=i
        while j>=1:
            if S[j-1]==">":
                if a[j-1]<=a[j]:
                    a[j-1]=a[j]+1
                j=j-1
            else:
                break
        k=i
        while k<=N:
            if S[k]=="<":
                if a[k+1]<=a[k]:
                    a[k+1]=a[k]+1
                k=k+1
            else:
                break
    i=i+1

a[0]=0
a[N+1]=0
print(sum(a))

Solution (Python):
S = input()

p = 0
l = []
for s in S:
    if s == '<':
        if p <= 0:
            p -= 1
        else:
            l.append(p)
            p = -1
    else:
        if p >= 0:
            p += 1
        else:
            l.append(p)
            p = 1
l.append(p)

n = len(l)
ans = 0

for ll in l:
    if ll < 0:
        ll *= -1
    for i in range(ll):
        ans += i


for i in range(n - 1):
    if l[i] < 0:
        ans += max(-l[i], l[i +1])

if l[0] > 0:
    ans += l[0]
if l[-1] < 0:
    ans -= l[-1]

print(ans)

Solution (Python):




s = input()
a = [0] * (len(s) + 1)

for i in range(0, len(s)):
    if (s[i] == '<'):
        a[i+1] = a[i] + 1
for i in range(len(s)-1, -1, -1):
    if (s[i] == '>'):
        a[i] = max(a[i], a[i+1]+1)

print(sum(a))

Solution (Python):
str = input()
cntl = []
cnt = 1
for i in range(len(str)-1):
    if str[i] == str[i+1]:
        cnt += 1
    else:
        cntl.append(cnt)
        cnt = 1
else:
    cntl.append(cnt)
s = 0
for i in range(len(cntl)):
    s += cntl[i]*(cntl[i]+1)//2
r = 0
if str[0] == "<":
    for i in range(len(cntl)//2):
        r += min(cntl[2*i],cntl[2*i+1])
if str[0] == ">":
    for i in range(1,(len(cntl)+1)//2):
        r += min(cntl[2*i-1],cntl[2*i])
print(s-r)

Solution (Python):
s = input()

total = 0
tmp_current = 0
tmp_high = float('inf')
count_from_high = 1
flag_current = False 
for c in s:
    if c == '<':
        if not flag_current:
            count_from_high = 0
        total += tmp_current+1
        tmp_current += 1
        flag_current = True
    else:
        if flag_current:
            tmp_high = tmp_current
            flag_current = False
        else:
            if tmp_high > count_from_high:
                total += count_from_high
            else:
                total += count_from_high + 1
        tmp_current = 0
        count_from_high += 1
print(total)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


S = readline().rstrip().decode('utf-8')

N = len(S)+1

from_left = [0]*N
from_right = [0]*N

for i,s in enumerate(S,1):
  if s == '>':
    from_left[i] = 0
  else:
    from_left[i] = from_left[i-1]+1
    
for i,s in enumerate(S[::-1]):
  i = N-2-i
  if s == '<':
    from_right[i] = 0
  else:
    from_right[i] = from_right[i+1]+1
    
seq = [x if x>y else y for x,y in zip(from_left, from_right)]

answer = sum(seq)
print(answer)

Solution (Python):
s=input()


g=[0 for i in range(len(s)+1)]
l=[0 for i in range(len(s)+1)]

for i in range(len(s)):
  if s[i]=="<":
    g[i+1]=g[i]+1

for i in range(len(s)-1,-1,-1):
  if s[i]==">":
    l[i]=l[i+1]+1
    
ans=0
for i in range(len(s)+1):
  ans+=max(g[i],l[i])

print(ans)

Solution (Python):
s = input()
a = [0] * (len(s)+1)

for i in range(len(s)):
  if s[i] == "<":
    a[i+1] = a[i] + 1

for i in range(len(s)-1, -1, -1):
  if s[i] == ">":
    a[i] = max(a[i], a[i+1]+1)

print(sum(a))

Solution (Python):
s=input()
n=len(s)+1
a=[0]*n
b=[0]*n
for i in range(n-1):
    if s[i]=='<':
        a[i+1]=a[i]+1
    if s[-i-1]=='>':
        b[i+1]=b[i]+1

print(sum([max(i,j) for i,j in zip(a,b[::-1])]))

Solution (Python):

S  = raw_input()
SS = ">"+S+"<"
N = len(SS) - 1
A = [None for i in xrange(N)]

for i in xrange(N):
    if (SS[i] == ">" and SS[i+1] == "<"):
        A[i] = 0
        j = 0
        while (i-j-1)>=0 and SS[i-j] == ">":
            if A[i-j-1] == None:
                A[i-j-1] = j+1
            else:
                Max = max(A[i-j-1], j+1)
                A[i-j-1] = Max
            j += 1
        j = 0
        while (i+j+1)<N and SS[i+j+1] == "<":
            if A[i+j+1] == None:
                A[i+j+1] = j+1
            else:
                Max = max(A[i+j+1], j+1)
                A[i+j+1] = Max
            j += 1

print sum(A)

Solution (Python):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    s = s.replace("><", ">_<").split("_")
    cnt = 0
    for sv in s:
        r = l = 0
        for i in range(len(sv)):
            if sv[i] == ">":
                r += 1
            else:
                l += 1
        cnt += r * (0 + r-1) // 2 + l * (0 + l-1) // 2 + max(r, l)
    print(cnt)


if __name__ == '__main__':
    solve()

Solution (Python):
from collections import deque

S = list(input())
sign = deque()
times = deque()


def total(number):
    answer = (number*(number+1))//2
    return answer



sign.append(S[0])
count = 1
for i in range(1,len(S)):
    if S[i] == S[i-1]:
        count += 1
    else:
        times.append(count)
        sign.append(S[i])
        count = 1
times.append(count)

sign = list(sign)
times = list(times)

answer = 0
for i in range(len(sign)):
    if i == 0 and sign[i] == ">":
        answer += total(times[i])
        continue
    if i == len(sign)-1 and sign[i] == "<":
        answer += total(times[i])
        continue
    if sign[i] == "<":
        answer += total(max(times[i],times[i+1]))
        answer += total(min(times[i],times[i+1])-1)

print(answer)

Solution (Python):
def solve(s):
    n = len(s)
    l = [0] * (n+1)
    r = [0] * (n+1)
    for i in range(n):
        l[i+1] = l[i]
        if s[i] == ">":
            l[i+1] = 0
        else:
            l[i+1] += int(s[i] == "<")
    for i in range(n-1, -1, -1):
        r[i] = r[i+1]
        if s[i] == "<":
            r[i] = 0
        else:
            r[i] += int(s[i] == ">")
    return sum([max(l[i], r[i]) for i in range(n+1)])

s = input()
print(solve(s))

Solution (Python):
S = input()
list = [100 for i in range(len(S))]
list.append(100)
cnt = 0
min = 0
if S[0] == "<":
	cnt = 1
	list[0] = 0
if S[-1] == ">":
	list[len(S)] = 0
for i in range(len(S)-1):
	if S[i] == ">" and S[i+1] == "<":
		list[i+1] = 0
		cnt = 1
for i in range(len(S)):
	if S[i] == "<":
		if list[i] == 0:
			cnt = 1
		list[i+1] = cnt
		cnt += 1


for i in range(len(S)-1):
	if S[len(S) - i - 1] == ">" and S[len(S) - i - 2] == "<":
		list[len(S) - i-1] = max(list[len(S) - i-1],list[len(S) - i]+1)
	elif S[len(S) - i - 1] == ">":
		list[len(S) - i-1] = list[len(S) - i]+1		
if S[0] == ">":
	list[0] = list[1] + 1

print(sum(list))

Solution (Python):
s=input()

list=[0 for _ in range(len(s) + 1)]

for n in range(0, len(s), 1):
    if '<' == s[n] and list[n] >= list[n + 1]:
        list[n + 1] += list[n] - list[n + 1] + 1

for n in range(len(s) - 1, -1, -1):
    if '>' == s[n] and list[n] <= list[n + 1]:
        list[n] += list[n + 1] - list[n] + 1

print(sum(list))

Solution (Python):
s = input()
buf = 0
str_len = len(s)
total = 0

while buf < str_len:
    l_count = 0
    r_count = 0

    while buf < str_len and s[buf] == "<":
        l_count += 1
        buf += 1

    while buf < str_len and s[buf] == ">":
        r_count += 1
        buf += 1

    f = lambda x : x * ( x + 1 ) // 2
    n = max(l_count, r_count)
    total += f(n)
    m = min(l_count, r_count) - 1
    total += f(m)

print(total)

Solution (Python):
s=input()

list=[0 for _ in range(len(s) + 1)]

def inc(n):
    if n < 0 or len(s) < n + 1:
        return
    if '<' == s[n]:
        if list[n] >= list[n + 1]:
            list[n + 1] += list[n] - list[n + 1] + 1
    elif '>' == s[n]:
        if list[n] <= list[n + 1]:
            list[n] += list[n + 1] - list[n] + 1

for i in range(0, len(s), 1):
    inc(i)

for i in range(len(s) - 1, -1, -1):
    inc(i)

print(sum(list))

Solution (Python):
def main():
  s = input().rstrip('\n')
  n = len(s)
  dp = [0] * (1 + n)
  for i,c in enumerate(s):
    if c == '<':
      dp[i+1] = dp[i] + 1
  for i in range(n-1, -1, -1):
    if s[i] == '>':
      dp[i] = max(dp[i], dp[i+1] + 1)
  return sum(dp)

print(main())

Solution (Python):
S = input()
A = [0] * (len(S) + 1)

for i in range(len(S)):
    if S[i] == "<":
        A[i + 1] = A[i] + 1

for i in range(len(S) - 1, -1, -1):
    if S[i] == ">":
        A[i] = max(A[i], A[i + 1] + 1)

print(sum(A))

Solution (Python):
s = input()
buf = 0
str_len = len(s)
total = 0

while buf < str_len:
    l_count = 0
    r_count = 0

    while buf < str_len and s[buf] == "<":
        l_count += 1
        buf += 1

    while buf < str_len and s[buf] == ">":
        r_count += 1
        buf += 1

    n = max(l_count, r_count)
    total += n * ( n + 1 ) // 2
    m = min(l_count, r_count) - 1
    total += m * ( m + 1 ) // 2

print(total)

Solution (Python):
s = input()                                                                                                                                                                                                                                                                                      
buf = 0                                                                                                                                                                                                                                                                                          
str_len = len(s)                                                                                                                                                                                                                                                                                 
total = 0                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                 
while buf < str_len:                                                                                                                                                                                                                                                                             
    l_count = 0                                                                                                                                                                                                                                                                                  
    r_count = 0                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                 
    while buf < str_len and s[buf] == "<":                                                                                                                                                                                                                                                       
        l_count += 1                                                                                                                                                                                                                                                                             
        buf += 1                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                 
    while buf < str_len and s[buf] == ">":                                                                                                                                                                                                                                                       
        r_count += 1                                                                                                                                                                                                                                                                             
        buf += 1                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                 
    n = max(l_count, r_count)                                                                                                                                                                                                                                                                    
    total += n * ( n + 1 ) // 2                                                                                                                                                                                                                                                                  
    m = min(l_count, r_count) - 1                                                                                                                                                                                                                                                                
    total += m * ( m + 1 ) // 2                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                 
print(total)

Solution (Python):
s = input()                                                                                                                                                                                                                                                                                      
buf = 0                                                                                                                                                                                                                                                                                          
str_len = len(s)                                                                                                                                                                                                                                                                                 
total = 0                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                 
while buf < str_len:                                                                                                                                                                                                                                                                             
    l_count = 0                                                                                                                                                                                                                                                                                  
    r_count = 0                                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                 
    while buf < str_len and s[buf] == "<":                                                                                                                                                                                                                                                       
        l_count += 1                                                                                                                                                                                                                                                                             
        buf += 1                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                 
    while buf < str_len and s[buf] == ">":                                                                                                                                                                                                                                                       
        r_count += 1                                                                                                                                                                                                                                                                             
        buf += 1                                                                                                                                                                                                                                                                                 
                                                                                                                                                                                                                                                                                                 
    n = max(l_count, r_count)                                                                                                                                                                                                                                                                    
    total += n * ( n + 1 ) // 2                                                                                                                                                                                                                                                                  
    m = min(l_count, r_count) - 1                                                                                                                                                                                                                                                                
    total += m * ( m + 1 ) // 2                                                                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                 
print(total)

Solution (Python):
S=input()
N=len(S)+1

a=[0]
temp=0
f=0
mx_idx=0

for i in range(1,N):
    if S[i-1]=="<":
        if f>=0:
            a.append(a[i-1]+1)
            temp+=1
            f=1
        else:
            if temp>0:
                for j in range(mx_idx+1,i):
                    a[j]-=temp
            elif temp<0:
                for j in range(mx_idx,i):
                    a[j]-=temp
            a.append(1)
            temp=1
            f=1
    else:
        if f<=0:
            a.append(a[i-1]-1)
            temp-=1
            f=-1
        else: 
            a.append(a[i-1]-1)
            temp-=1
            mx_idx=i-1
            f=-1

if temp<0:
    for j in range(mx_idx, N):
        a[j] -= temp
print(sum(a))

Solution (Python):

import math


S = input()

list = []
list.append(0)

for i in range(len(S)) :
  if S[i] == "<" :
    list.append(list[i] + 1)
  else :
    list.append(0)


for j in reversed(range(len(list))) :
  if j != len(list)-1 :
    if S[j] == ">" :
      val = list[j+1] + 1
      if list[j] < val :
        list[j] = val

sum = 0      
for k in range(len(list)) :
  sum += list[k]


print (sum)

Solution (Python):
S = input()
ans = [0]*(len(S) + 1)
temp = 0
for i, s in enumerate(S):
    if s == '<':
        ans[i+1] = ans[i] + 1
for i, s in reversed(list(enumerate(S))):
    if s == '>' :
        ans[i] = max(ans[i+1] + 1, ans[i])
print(sum(ans))

Solution (Python):
s = input().replace('><', '> <').split()
ans = 0
for s_ in s:
    a = s_.count('<')
    b = len(s_) - a
    if a < b:
        ans += a * (a - 1) //  2
        ans += b * (b + 1) // 2
    else:
        ans += a * (a + 1) //  2
        ans += b * (b - 1) // 2
print(ans)

Solution (Python):
S = input()
l_1 = [0]
l_2 = [0]
for i in range(len(S)):
  if S[i] == '<':
    l_1.append(l_1[i] + 1)
  else:
    l_1.append(0)
for i in range(len(S)):
  if  S[len(S)-i-1] == '>':
    l_2.append(l_2[i] + 1)
  else:
    l_2.append(0)
l_2.reverse()
l_3 = []
for i in range(len(S)+1):
  l_3.append(max(l_1[i], l_2[i]))
print(sum(l_3))

Solution (Python):
import numpy as np


def foo(x, y):
    return y * (y + 1) // 2 + x * (x - 1) // 2

S = input().strip()
if S[0] == '>':
    S = '<' + S
if S[-1] == '<':
    S = S + '>'

s = [S[0]]
n = [0]
for si in S:
    if si == s[-1]:
        n[-1] += 1
    else:
        s.append(si)
        n.append(1)

n1, n2 = np.sort(np.array(n).reshape((-1, 2)), axis=-1).T
print(np.sum(foo(n1, n2)))

Solution (Python):
import sys
data = sys.stdin.readline().replace('\n', '')

indexes = []
def csum(a):
    return (a + 1) * a / 2
prev = 0
for element in range(1, len(data)):
    if data[element - 1] == '>' and data[element] == '<':
        indexes.append((prev, element - 1))
        prev = element
indexes.append((prev, len(data) - 1))
ans = 0
for x, y in indexes:
    fnd = False
    len = y - x + 1
    for i in range(x, y):
        if data[i] == '<' and data[i + 1] == '>':
            a = i - x + 1
            b = y - i
            if a > b:
                ans += csum(a)
                ans += csum(b - 1)
            else:
                ans += csum(b)
                ans += csum(a - 1)

            fnd = True
            break
    if not fnd:
        ans += csum(len)
print ans

Solution (Python):
s = input()
ans = [0 for i in range(len(s)+1)]
for i in range(len(s)):
    if s[i:i+1] == "<":
        ans[i+1] = max(ans[i],ans[i]+1)
for i in range(len(s)):
    if s[len(s)-i-1:len(s)-i] == ">":
        ans[len(s)-i-1] = max(ans[len(s)-i-1],ans[len(s)-i]+1)
print(sum(ans))