import strutils, sequtils let Awb, Bwb, CD = stdin.readLine.split.map parseInt (C, D) = (CD[0], CD[1]) var white = (numA: Awb[0], numB: Bwb[0]) black = (numA: Awb[1], numB: Bwb[1]) num = C - black.numA white.numA -= num white.numB += num white.numA += min(D, white.numB) echo white.numA