def solution(dirs):
an = {}
U = 0 ; D = 0 ;R = 0 ; L = 0
location = [0,0]
for i in dirs:
road = str(location)
if i == 'L':
if location[0] == -5:
pass
else:
location[0] -= 1
a = str(location)
road1 = a+road
road += a
if (road not in an) and (road1 not in an):
an[road]=0
elif i == 'R':
if location[0] == 5:
pass
else:
location[0] += 1
a = str(location)
road1 = a+road
road += a
if (road not in an) and (road1 not in an):
an[road]=0
elif i == 'U':
if location[1] == 5:
pass
else:
location[1] += 1
a = str(location)
road1 = a+road
road += a
if (road not in an) and (road1 not in an):
an[road]=0
elif i == 'D':
if location[1] == -5:
pass
else:
location[1] -= 1
a = str(location)
road1 = a+road
road += a
if (road not in an) and (road1 not in an):
an[road]=0
answer = len(an)
return answer