Day 10: Keep on the Trail!

Another elf wants to go and find some caches! The trouble is, he doesn't know which ones are part of the trail he is doing. The elf who placed them didn't number them in the title! The elf has a list of caches, and which caches they are next to. A relationship between caches is both ways. How many caches are between the start and end cache, including both endpoints? Here is your test input:

Example

Input

lvh -> start
bbt -> end
zpy -> jql
yrl -> jif
zpy -> lvh
jql -> yrl
end -> puo
puo -> yrl
ebf -> zpy
uzm -> lvh
puo -> mug

Output

7

Alert: You are about to download a file that contains details needed to find this geocache. As the geocache owner, I ensure that this file is safe to download. It has not been checked by Geocaching HQ or by the reviewer for possible malicious content. Download this file at your own risk.

Download input data:

Input Data File