output_description: If S consists of exactly two kinds of characters which both appear twice in S,
  print `Yes`; otherwise, print `No`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: # coding: utf-8
  # Your code here!
  
  N, M = map(int, input().split())
  hen = [list(map(int, input().split())) for i in range(M)]
  S, T = map(int, input().split())
  hen2 = []
  for i in range(N):
      a = []
      for j in hen:
          if j[0] == i + 1:
              a.append(j[1])
      hen2.append(a)
  
  queue = [[S, 0]]
  check = []
  dist = [0]
  
  while True:
      if queue == []:
          print(-1)
          break
      Now = queue.pop(0)
      ndist = dist.pop(0)
      if Now == [T, 0]:
          print(int(ndist / 3))
          break
  
      check.append(Now)
      for i in hen2[Now[0] - 1]:
          if [i, (Now[1] + 1) % 3] not in check:
              queue.append([i, (Now[1] + 1) % 3])
              dist.append(ndist + 1)
  
problem_description: Statement
  
  You are given a 4-character string S consisting of uppercase English letters.
  Determine if S consists of exactly two kinds of characters which both appear
  twice in S.
samples: [{"input": "ASSA", "output": "Yes\n    \n\nS consists of `A` and `S` which both appear twice in S.\n\n* * *"}, {"input": "STOP", "output": "No\n    \n\n* * *"}, {"input": "FFEE", "output": "Yes\n    \n\n* * *"}, {"input": "FREE", "output": "No"}]