Harryxun/stf_run huggingface dataset:
#create date: 2020-07-03 14:46

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    h, w = na()
    g = [[1] * (w+2)]
    white = 0
    for i in range(h):
        r = ns()
        white += r.count(".")
        g.append([1] + [1 if s=="#" else 0 for s in r] + [1])
    g.append([1] * (w+2))
    q = deque([[1,1]])
    move = ((1, 0), (-1, 0), (0, 1), (1, 0))
    while q:
        x, y = q.popleft()
        for dx, dy in move:
            nx, ny = x + dx, y + dy
            if g[nx][ny] > 0:
                continue
            g[nx][ny] = g[x][y] + 1
            q.append((nx, ny))
    if g[h][w] = 0:
        print(-1)
    else:
        print(white - g[h][w] - 1)



if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-07-03 14:46

import sys
stdin = sys.stdin
from collections import deque

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    h, w = na()
    g = [[1] * (w+2)]
    white = 0
    for i in range(h):
        r = ns()
        white += r.count(".")
        g.append([1] + [1 if s=="#" else 0 for s in r] + [1])
    g.append([1] * (w+2))
    q = deque([[1,1]])
    move = ((1, 0), (-1, 0), (0, 1), (0, -1))
    while q:
        x, y = q.popleft()
        for dx, dy in move:
            nx, ny = x + dx, y + dy
            if g[nx][ny] > 0:
                continue
            g[nx][ny] = g[x][y] + 1
            q.append((nx, ny))
    if g[h][w] == 0:
        print(-1)
    else:
        print(white - g[h][w] - 1)



if __name__ == "__main__":
    main()
import sys

def solve(s: str, t: str):
    ls=len(s)
    lt=len(t)
    dp=[[0]*(lt+1) for _ in range(ls+1)] # dp[0:ls+1][0:lt+1]

    for i in range(ls):
        for j in range(lt):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            if dp[i+1][j]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i+1][j]
            if dp[i][j+1]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i][j+1]

    ans=""
    la=dp[ls][lt]
    ttag=lt
    for i in reversed(range(ls+1)):
        if dp[i][ttag]<la:
            ans=s[i]+ans                                                                                                                                                      la-=1
            ttag-=1

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def solve(s: str, t: str):
    ls=len(s)
    lt=len(t)
    dp=[[0]*(lt+1) for _ in range(ls+1)] # dp[0:ls+1][0:lt+1]

    for i in range(ls):
        for j in range(lt):
            if s[i]==t[j]:
                dp[i+1][j+1]=dp[i][j]+1
            if dp[i+1][j]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i+1][j]
            if dp[i][j+1]>dp[i+1][j+1]: dp[i+1][j+1]=dp[i][j+1]

    ans=""
    while ls>0 and lt>0:
        if dp[ls][lt]==dp[ls-1][lt]:
            ls-=1
        elif dp[ls][lt]==dp[ls][lt-1]:
            lt-=1
        else:
            ans=s[ls-1]+ans
            ls-=1
            lt-=1

    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)

if __name__ == '__main__':
    main()
s=[int(j) for j in input()][::-1]
c=[0]*2019
tmp=0
c[0]+=1
t=1
import numpy as np
for i in s:
    tmp+=t*i
    c[tmp%2019]+=1
    t*=10
c=np.array(c)
ans=c*(c-1)//2
print(ans.sum())



### FIXED CODE ###

s=[int(j) for j in input()][::-1]
c=[0]*2019
tmp=0
c[0]+=1
t=1
import numpy as np
for i in s:
    tmp+=t*i
    c[tmp%2019]+=1
    t=t*10%2019
c=np.array(c)
ans=c*(c-1)//2
print(ans.sum())
a,b,t=map(int,input.split())
if t > a:print(b*(t//a))
else:print(0)

### FIXED CODE ###

a,b,t=map(int,input().split())
print(b*(t//a))
"""
切り捨て除算なので場合分けはいらない
input()にしなかった私が悪うございました(￣^￣)
"""
print("NYoe s"[int(input())[:4]::2])

### FIXED CODE ###

print("NYoe s"[input()[:4]=="YAKI"::2])
def resolve():
	s = input()
	k = int(input())
	if len(s) == 1:
		print(s)
		return

	for i in s:
		if int(i) == 1:
			continue
		print(i)
		return
resolve()

### FIXED CODE ###

def resolve():
	a, b = map(int, input().split())
	print(a*b - (a+b-1))
resolve()
A = int(input())
B = int(input())
if A>=10 or B>10:
  print(-1)
else:
  print(A*B)

### FIXED CODE ###

A,B = map(int,input().split())
if A>=10 or B>=10:
   print(-1)
else:
   print(A*B)
from collections import deque

def cndP(l,n,p1,p2):
    d = set()
    length = len(l)
    for i in range(length-n+1):
        s = sum(l[i:i+n])
        if p2 == None:
            if p1 < s:
                d.add(s)
        else:
            if p1 < c < p2:
                d.add(s)
    return sorted(d)

def pIsAccptbl(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

n,k = [int(x) for x in input().split()]
w = []
for i in range(n):
    e = int(input())
    w.append(e)

n=2
p = max(w)
p1 = p
p2 = None

if(pIsAccptbl(w,k,p)):
    print(p)
else:
    while(1):
        s = cndP(w,n,p1,p2)
        if s==[]:
            break;
        for i in s:
            if(pIsAccptbl(w,k,i)):
                p2 = i
                break
            p1 = i
        n+=1

### FIXED CODE ###

from collections import deque

def isPa(w,k,p):
    tr = 0
    c = 0
    d = deque(w)
    while(d):
        tmp = d.popleft()
        if(tmp > p):
            return False
        
        if( tr + tmp > p):
            tr = tmp
            c += 1
        else:
            tr += tmp
        if c+1>k:
            return False
    return True

def MaxInP(w,k,p):
    maxinp = 0
    tmp = 0
    d = deque(w)
    while(d):
        tmp += d.popleft();
        if(tmp > p):
            if(tmp > maxinp):
                maxinp = tmp
            tmp = 0
    return maxinp

n,k = [int(x) for x in input().split()]
w = deque()
for i in range(n):
    w.append(int(input()))
    
mean = int(sum(w)/k)
maxinp = MaxInP(w,k,mean)

if k == 1:
    print(mean)
else:
    minP = mean
    maxP = maxinp
    while(True):
        m = int ((minP + maxP)/2)
        if ( isPa(w,k,m) ):
            maxP = m
        else:
            minP = m
        if (minP+1 == maxP or minP == maxP):
            print(maxP)
            break
H = int(input())
W = int(input())
N = int(input())
import math
print(int(math.ceil(N // max(H, W)))

### FIXED CODE ###

H = int(input())
W = int(input())
N = int(input())
import math
print(int(math.ceil(N / max(H, W))))
n = int(input())
vl = [int(input()) for _ in range(n)]
cl = [int(input()) for _ in range(n)]
ans = 0
for i in range(n):
    if vl[i] > cl[i]:
        ans += v[i]-c[i]
print(ans)

### FIXED CODE ###

n = int(input())
vl = list(map(int, input().split()))
cl = list(map(int, input().split()))
ans = 0
for i in range(n):
    if vl[i] > cl[i]:
        ans += vl[i]-cl[i]
print(ans)
k, a, b = [int(i) for i in input().split()]

sum = 0
if a >= b:
    # A >= Bの場合
    sum = 1 + (k - 2) + (b - a) 
else:
    # A < B の場合
    diff = b - a
    if diff == 1:
        # a,bに１施行ずつ使い、それ以外は叩く、という選択
        sum = 1 + (k - 2) + 1
    elif diff == 2:
        # a,bに１施行ずつ使い、それ以外は叩く、という選択(a,bで + 2 なのでall叩くと同じスコア)
        sum = 1 + k
    else:
        # a->bコンボが利潤を生み続けるパターン
        print("a")
        k = 1 + k - a
        if k % 2 == 0:
            sum = a + ((diff) * (k / 2))
        else:
            # 最後1回はコンボができないので、叩くパターン
            print("b")
            sum = a + ((diff) * ((k - 1) / 2)) + 1

print(sum)

### FIXED CODE ###

n,k = [int(i) for i in input().split()]

# n以下の奇数の数をカウント
cnt = 0
for i in range(1, n+1):
    if i % 2 == 1:
        cnt+=1

if cnt >= k:
    print('YES')
else:
    print('NO')
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,*a=map(int,read().split())
	
	aa=max(a)
	
	li=[[] for _ in range(aa+1)]
	
	for i in range(n):
		li[a[i]].append(i)
	
	if len(li[0])>3:
		print(0)
		exit(0)
	else:
		ans=3 if len(li[0])==1 else 6

	for i in range(1,aa+1):
		if len(li[i])>3:
			print(0)
			exit(0)
		else:
			k=bisect.bisect_left(li[i-1],li[i][0])
			ans*=k
			ans%=MOD
			
			if len(li[i])>1:
				k=bisect.bisect_left(li[i-1],li[i][1])-1
				ans *= k
				ans %= MOD
		
	print(ans)
	
	
if __name__ == "__main__":
		main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
#from collections import deque
#from collections import defaultdict
# from collections import Counter
#from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n,*a=map(int,read().split())
	
	aa=max(a)
	
	li=[[] for _ in range(aa+1)]
	
	for i in range(n):
		li[a[i]].append(i)
	
	if len(li[0])>3 or len(li[0])==0:
		print(0)
		exit(0)
	else:
		ans=3 if len(li[0])==1 else 6
	for i in range(1,aa+1):
		if len(li[i])>3 or len(li[i])==0 or len(li[i])>len(li[i-1]):
			print(0)
			exit(0)
		else:
			k=bisect.bisect_right(li[i-1],li[i][0])
			ans*=k
			ans%=MOD
			
			if len(li[i])>1:
				k=bisect.bisect_right(li[i-1],li[i][1])-1
				ans *= k
				ans %= MOD
		
	print(ans)
	
	
if __name__ == "__main__":
		main()
N=input()
c=0
flag = 0
for i in N:
    if i=='C' and  c==0 :c+=1
    if i=='F' and c==1: flag=1
if flag==:print("Yes")
else :print("No")

### FIXED CODE ###

N=input()
c=0
flag = 0
for i in N:
    if i=='C' and  c==0 :c+=1
    if i=='F' and c==1: flag=1
if flag==1:print("Yes")
else :print("No")
# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
from collections import defaultdict


_, S, _, *Q = open(0).read().split()
S = list(S)
Q = tuple(zip(*[iter(Q)]*3))

D = defaultdict(list)

for i, s in enumerate(S):
    D[s].append(i)

for q, *x in Q:
    if int(q) == 1:
        i, c = x
        i = int(i) - 1

        d = D[S[i]]
        i = bisect_left(d, i)
        d.pop(i)

        d = D[c]
        insort_left(d, i)

        S[i] = c

    else:
        l, r = map(int, x)
        l -= 1
        r -= 1
        cnt = 0
        for L in D.values():
            i = bisect_left(L, l)
            if i == len(L):
                continue
            if L[i] <= r:
                cnt += 1

        print(cnt)


### FIXED CODE ###

# AtCoder Beginner Contest 157
# E - Simple String Queries
# https://atcoder.jp/contests/abc157/tasks/abc157_e
from bisect import bisect_left, insort_left
import sys
input = sys.stdin.readline
OFS = ord('a')
_ = input()
S = list(input()[:-1])

D = [[] for _ in [0]*26]
for i, s in enumerate(S):
    D[ord(s)-OFS].append(i)

for _ in [0]*int(input()):
    Q = input()[:-1].split()
    if Q[0] == '1':
        i, c = int(Q[1])-1, Q[2]

        if S[i] != c:
            s = ord(S[i])-OFS
            D[s].pop(bisect_left(D[s], i))
            insort_left(D[ord(c)-OFS], i)
            S[i] = c

    else:
        l, r = int(Q[1])-1, int(Q[2])-1

        cnt = 0
        for L in D:
            i = bisect_left(L, l)
            if i < len(L) and L[i] <= r:
                cnt += 1

        print(cnt)
anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = 0;bsum = 0
ans = 0;a = 0;b = 0
while asum + alist[a] <= acc:
    asum += alist[a];a+=1
    if a == anum:
        break

while asum + blist[b] <= acc:
    bsum += blist[b];b += 1
    if b == bnum:
        break

if a == 0 and b == 0:
    pass
elif b == bnum:
    ans = a + b
else:
    ans = a + b
    for i in range(a):
        while asum - alist[a-(i+1)] + bsum + blist[b] <= acc:
            bsum += blist[b];b += 1
            if a + b > ans:
                ans = a + b
            if b == bnum:
                break

print(ans)


### FIXED CODE ###

anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = [0]
bsum = [0]
ans = 0
for i in range(anum):
    asum.append(asum[i]+alist[i])
for i in range(bnum):
    bsum.append(bsum[i]+blist[i])

b = bnum
for a in range(anum+1):
    if asum[a] > acc:
        break
    while asum[a] + bsum[b] > acc:
        b -=1
    ans = max(ans,a+b)

print(ans)
N = int(input())
X = []
Y = []
H = []
for _ in range(N):
    x, y, h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

C = [[-1 for _ in range(101)] for _ in range(101)]
for i in range(101):
    for j in range(101):

        need = -1
        for n in range(N):
            if H[n] > 0:
                tmp = H[n] + abs(X[n]-i) + abs(Y[n]-j)
            if need == -1:
                need = tmp
            else:
                if need != tmp:
                    need = -2
                    break
        if need == -2:
            continue

        for n in range(N):
            if H[n] == 0:
                tmp = H[n] + abs(X[n] - i) + abs(Y[n] - j)
                if need > tmp:
                    need = -2
                    break
        if need == -2:
            continue

        print(i, j, need)
        exit()


### FIXED CODE ###

N = int(input())
X = []
Y = []
H = []
xc = None
yc = None
hc = None
for _ in range(N):
    x, y, h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    if h > 0:
        xc = x
        yc = y
        hc = h

for pos_x in range(101):
    for pos_y in range(101):
        center_h = hc + abs(xc - pos_x) + abs(yc - pos_y)

        flag = True
        for n in range(N):
            if H[n] != max(center_h - abs(X[n] - pos_x) - abs(Y[n] - pos_y), 0):
                flag = False
                break
        if flag:
            print(pos_x, pos_y, center_h)
            exit()
from collections import Counter

N=input()
A=map(int, raw_input().split())

C=Counter(A)

if len(C)%3==0:
	a,b,c=C.keys()
	if N%3==0:
		if a^b==c:
			print "Yes"
		else:
			print "No"
else:
	if len(C)==1:
		if C.keys()==[0]:
			print "Yes"
		else:
			print "No"
	else:
		print "No"


### FIXED CODE ###

from collections import Counter

N=input()
A=map(int, raw_input().split())

for i,x in enumerate(A):
	if i==0:
		t=x
	else:
		t^=x

if t==0:
	print "Yes"
else:
	print "No"
n,m=map(int,input().split())
sc=[]
for i in range(m):
  q=list(map(int,input().split()))
  if q not in sc:
    sc.append(q)
slist=[i[0] for i in sc]
if len(slist)!=len(set(slist)):
  print("-1")
  exit()
if n!=1 and [1,0] in sc:
  print(-1)
  exit()
if n==1 and sc == [[1,0]]:
  print(0)
  exit()

sc.sort()
num=""
k=0
sc.append(n+1)
for i in range(1,n+1):
  if sc[k][0]==i:
    num += str(sc[k][1])
    k+=1
  else:
    if i==1:
      num+="1"
    else:
      num += "0"
print(int(num))

### FIXED CODE ###

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
# 全探索
if n==1:
  for i in range(10):
    memo=0
    for li in sc:
      if str(i)[li[0]-1]!=str(li[1]):
        break
      else:
        memo+=1
    if memo==m:
      print(i)
      exit()
  print("-1")
elif n==2:
  for i in range(10,100):
    memo=0
    for li in sc:
      if str(i)[li[0]-1]!=str(li[1]):
        break
      else:
        memo+=1
    if memo==m:
      print(i)
      exit()
  print("-1")
else:
  for i in range(100,1000):
    memo=0
    for li in sc:
      if str(i)[li[0]-1]!=str(li[1]):
        break
      else:
        memo+=1
    if memo==m:
      print(i)
      exit()
  print("-1")
from collections import Counter
from math import factorial
N,A,B = map(int,input().split())
V=list(map(int,input().split()))

V_C=Counter(V)

max_val=max(V)
CC=V_C[max_val]
if A<=CC<=B:
    ans=0
    for v in range(A,min(B+1,CC+1)):
        ans+=factorial(CC)//factorial(v)//factorial(CC-v)
    print(max_val)
    print(ans)
    exit()


tmp_sum=0
tmp_num=0

for key in sorted(V_C.keys(),reverse=True):
    val = V_C[key]
    if tmp_num+val<=B:
        tmp_num+=val
        tmp_sum+=key*val
        if tmp_num>=A:
            break
    else:
        break

if A<=tmp_num<=B:
    assert 1==2
    print(tmp_sum/tmp_num)
    print(1)
else:
    assert 1==2
    rest=A-tmp_num
    tmp_num+=rest
    tmp_sum+=key*rest
    print(tmp_sum/tmp_num)
    print(factorial(val)//factorial(rest)//factorial(val-rest))





### FIXED CODE ###

from collections import Counter
from collections import Counter
N, A, B = (list)(map(int, input().split()))
v = (list)(map(int, input().split()))

v = sorted(v, reverse=True)

sel_list = v[:A]
max_ave = sum(sel_list)/A
print(max_ave)

c = Counter(v)


def comb(n, r):
    r = min(r, n-r)
    ret = 1
    for i in range(r):
        ret *= (n-i)/(i+1)
    return ret


def ave_n(n):
    sel_list = v[:n]
    ave = sum(sel_list)/i
    if ave != max_ave:
        return 0
    last = sel_list[-1]
    use_last = sel_list.count(last)
    return comb(c[last], use_last)


ans = 0
for i in range(A, B+1):
    ret = ave_n(i)
    if ret == 0:
        break
    else:
        ans += ret
print((int)(ans))
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    for i in range(1, 101):
        if i in p:
            continue

        if i <= x:
            ans = i
        elif x - ans > i - x:
            ans = i
    else:
        print(ans)


if __name__ == '__m

### FIXED CODE ###

# import numpy as np
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    ans = x
    for i in range(-1, 102):
        if i in p:
            continue

        if i <= x:
            ans = i
        else:
            if x - ans > i - x:
                ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()
N = str(input())
if str[0] == "7" or str[1] == "7" or str[2] == "7":
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N = str(input())
if N[0] == "7" or N[1] == "7" or N[2] == "7":
  print("Yes")
else:
  print("No")
import math
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int(math.sqrt(p+1))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

### FIXED CODE ###

n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p+1)**(1/n))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)
S = list(input())
last = len(S) - 1

S_head = S[0]

S_clone = S
S_bothEnd = [S[0],S[1],S[last]]
S_center = list(set(S)-set(S_bothEnd))

S_clone.remove('A')
S_clone.remove('C')

evalLow = "".join(S_clone)

if S_head == "A" and S_center.count("C")  == 1 and evalLow.islower() == 1:
  print('AC')
else:
  print('WA')

### FIXED CODE ###

S = list(input())
last = len(S) - 1

S_head = S[0]

S_bothEnd = [S[0],S[1],S[last]]
S_center = list(set(S)-set(S_bothEnd))

S_clone = S
if "A" in S_clone:
  S_clone.remove('A')
if "C" in S_clone:
  S_clone.remove('C')

evalLow = "".join(S_clone)

if S_head == "A" and S_center.count("C")  == 1 and evalLow.islower() == 1:
  print('AC')
else:
  print('WA')
S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
for i in range(n - 1):
    if S[i] == '>' and S[i + 1] == ('<'):
        temp = i
        break
if S[0] == '<':
    temp = -1
ans += (temp + 1) * (temp + 2) // 2
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) // 2 + r * (r + 1) // 2
print(ans)

### FIXED CODE ###

S = input()
n = len(S)
S = S + " "
ans = 0
l = 0
r = 0
temp = 0

if S[0] == '<':
    temp = 0
else:
    for i in range(n):
        if S[i] == '>' and S[i + 1] == ('<'):
            temp = i+1
            break
        if i == n - 1:
            print((n + 1) * n // 2)
            exit()
ans += (temp) * (temp + 1) // 2
i = max(temp, 0)

while(i < n):
    while (i < n and S[i] == '<'):
        l += 1
        i += 1
    while (i < n and S[i] == '>'):
        r += 1
        i += 1
    l, r = min(l, r), max(l, r)
    ans += l * (l - 1) // 2 + r * (r + 1) // 2
    l = 0
    r = 0

l, r = min(l, r), max(l, r)
ans += l * (l - 1) // 2 + r * (r + 1) // 2
print(ans)