# Help Sally Crash Into Her Father

Sally is a very bad skater, so she can only skate in one direction! But Sally still wants to find her dad in the least amount of moves possible so that she can get off the ice. Sally's only way of stopping is (crashing into) walls or the edge of the ice rink.

We describe the ice rink using the following notation:

(#) -- Wall
(.) -- Free space
(S) -- Sally's starting position

For example, in the ice rink at right, the shortest path is 18 steps.

Here is a text file of 5 ice rinks of size $$20 \times 20$$. The rinks are separated by hyphens.

Find the sum of the shortest paths of these five $$20 \times 20$$ ice rinks.

Note: Sally has to stop at her father's position. She will slide past him if there are no walls.

×