import sys s = sys.stdin.read()[:-1] cp = (0,0) P = {cp} dep = { '<':(1,0), '>':(-1,0), 'v':(0,1), '^':(0,-1), } for c in s: x,y = cp dx,dy = dep[c] cp = (x+dx,y+dy) P.add(cp) print(len(P))