output_description: Print the number of cups with a possibility of eventually containing the ball.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N Q
      A_1 B_1
      A_2 B_2
      :          
      A_Q B_Q
attempt: N, Q = map(int, input().split())
  AB = [list(map(int, input().split())) for _ in range(Q)]
  
  ans = 1
  anls = set([1])
  ansidx = 0
  ray = [e for e in range(0, N)]
  anls.add(ray[1])
  
  for e, (a, b) in enumerate(AB):
      a, b = a - 1, b - 1
      ray[a], ray[b] = ray[b], ray[a]
      if ansidx != 0:
          anls.add(ray[ansidx - 1])
      if ansidx != N - 1:
          anls.add(ray[ansidx + 1])
  print(len(anls))
  
problem_description: Statement
  
  You have N cups and 1 ball.
  
  The cups are arranged in a row, from left to right.
  
  You turned down all the cups, then inserted the ball into the leftmost cup.
  
  Then, you will perform the following Q operations:
  
    * The i-th operation: swap the positions of the A_i-th and B_i-th cups from the left. If one of these cups contains the ball, the ball will also move.
  
  Since you are a magician, you can cast a magic described below:
  
    * Magic: When the ball is contained in the i-th cup from the left, teleport the ball into the adjacent cup (that is, the (i-1)-th or (i+1)-th cup, if they exist).
  
  The magic can be cast before the first operation, between two operations, or
  after the last operation, but you are allowed to cast it at most once during
  the whole process.
  
  Find the number of cups with a possibility of containing the ball after all
  the operations and possibly casting the magic.
samples: [{"input": "10 3\n    1 3\n    2 4\n    4 5", "output": "4\n    \n\n* * *"}, {"input": "20 3\n    1 7\n    8 20\n    1 19", "output": "5"}]