✅ 정답 공개
from collections import deque
start = input().strip()
end = input().strip()
word_list = set(input().split())
if end not in word_list:
print(0)
else:
q = deque([(start, 1)])
visited = {start}
result = 0
while q:
word, step = q.popleft()
if word == end:
result = step
break
for i in range(len(word)):
for c in 'abcdefghijklmnopqrstuvwxyz':
nw = word[:i] + c + word[i+1:]
if nw in word_list and nw not in visited:
visited.add(nw)
q.append((nw, step+1))
print(result)