output_description: Print the minimum number of operations required.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      P_1
      :
      P_N
attempt: a, b, c, k = map(int, input().split())
  if k % 2 == 0:
      print(a - b)
  else:
      print(b - a)
  
problem_description: Statement
  
  You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the
  integers from 1 through N. You would like to sort this sequence in ascending
  order by repeating the following operation:
  
    * Choose an element in the sequence and move it to the beginning or the end of the sequence.
  
  Find the minimum number of operations required. It can be proved that it is
  actually possible to sort the sequence using this operation.
samples: [{"input": "4\n    1\n    3\n    2\n    4", "output": "2\n    \n\nFor example, the sequence can be sorted in ascending order as follows:\n\n  * Move 2 to the beginning. The sequence is now (2,1,3,4).\n  * Move 1 to the beginning. The sequence is now (1,2,3,4).\n\n* * *"}, {"input": "6\n    3\n    2\n    5\n    1\n    4\n    6", "output": "4\n    \n\n* * *"}, {"input": "8\n    6\n    3\n    1\n    2\n    7\n    4\n    8\n    5", "output": "5"}]