29 lines
357 B
Python
29 lines
357 B
Python
import sys
|
|
|
|
s = sys.stdin.read()[:-1]
|
|
|
|
cpS = (0,0)
|
|
cpR = (0,0)
|
|
P = {cpS}
|
|
|
|
dep = {
|
|
'<':(1,0),
|
|
'>':(-1,0),
|
|
'v':(0,1),
|
|
'^':(0,-1),
|
|
}
|
|
|
|
for i,c in enumerate(s):
|
|
dx,dy = dep[c]
|
|
if i%2:
|
|
x,y = cpS
|
|
cpS = (x+dx,y+dy)
|
|
P.add(cpS)
|
|
else:
|
|
x,y = cpR
|
|
cpR = (x+dx,y+dy)
|
|
P.add(cpR)
|
|
|
|
print(len(P))
|
|
|