output_description: Print the maximum possible sum of the numbers written on the cards chosen.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      A B C K
attempt: A, B, C, K = list(map(int, input().split(" ")))
  sumv = 0
  sumv += A
  remain = K - A
  use_B = min(B, remain)
  use_C = remain - use_B
  sumv += -1 * use_C
  print(sumv)
  
problem_description: Statement
  
  We have A cards, each of which has an integer 1 written on it. Similarly, we
  also have B cards with 0s and C cards with -1s.
  
  We will pick up K among these cards. What is the maximum possible sum of the
  numbers written on the cards chosen?
samples: [{"input": "2 1 1 3", "output": "2\n    \n\nConsider picking up two cards with 1s and one card with a 0. In this case, the\nsum of the numbers written on the cards is 2, which is the maximum possible\nvalue.\n\n* * *"}, {"input": "1 2 3 4", "output": "0\n    \n\n* * *"}, {"input": "2000000000 0 0 2000000000", "output": "2000000000"}]