from itertools import*

g=[(c>'<',len(list(m)))for c,m in groupby(eval(input()))]

n=len(g)

a=b=0

for i,(c,m)in enumerate(g):

  a+=m*~-m//2+max(m,b)*c+m*(c^1)*(i>n-2)

  b=m

print(a)
from itertools import*

a=b=0

for c,m in groupby(eval(input())):m=len(list(m));a+=m*-~m//2-min(m,b)*(c>'<');b=m

print(a)
from itertools import *

g = [(c > "<", len(list(m))) for c, m in groupby(eval(input()))]
n = len(g)
a = b = 0
for i, (c, m) in enumerate(g):
    a += m * ~-m // 2 + max(m, b) * c + m * (c ^ 1) * (i > n - 2)
    b = m
print(a)

from itertools import *

a = b = 0
for c, m in groupby(eval(input())):
    m = len(list(m))
    a += m * -~m // 2 - min(m, b) * (c > "<")
    b = m
print(a)

-g = [(c > "<", len(list(m))) for c, m in groupby(eval(input()))] -n = len(g) -for i, (c, m) in enumerate(g): -    a += m * ~-m // 2 + max(m, b) * c + m * (c ^ 1) * (i > n - 2) +for c, m in groupby(eval(input())): +    m = len(list(m)) +    a += m * -~m // 2 - min(m, b) * (c > "<")