text: #Uses python3
  
  import sys
  
  def explore(adj, u):
      visited[u] = 1
      for vertex in adj[u]:
          if visited[vertex] == 0:
              explore(adj, vertex)
  
  if __name__ == '__main__':
      n, m = map(int, input().split())
      data = []
      for i in range(m):
          a, b = map(int, input().split())
          data.append(a)
          data.append(b)
      u, v = map(int, input().split())
      data = list(zip(data[0::2], data[1::2])) # edges
  
      visited = [0 for _ in range(n)] # keeps track of vertices visited when we explore u
      adj = [[] for _ in range(n)] # initialize adjacency list
      for (a, b) in data:
          adj[a-1].append(b-1)
          adj[b-1].append(a-1)
  
      u -= 1
      v -= 1
  
      # we explore u fully here and check if v was ever visited
      # we could also keep a flag with which we can stop exploring further once v is visited
      explore(adj, u) 
      print(visited[v])
      