OPEN telein.txt
N ← int(first line)
directions ← second line
CLOSE telein.txt
visited ← empty set
position ← 0
add 0 to visited
FOR direction in directions DO
IF direction = "T" DO
position ← 0
ELSE IF direction = "R" DO
position += 1
ELSE IF direction = "L" DO
position -= 1
END IF
add position to visited
END FOR
OPEN teleout.txt
write length of visited
CLOSE teleout.txt