import strutils, sequtils let Awb, Bwb, CD = stdin.readLine.split.map parseInt (C, D) = (CD[0], CD[1]) var A = (w: Awb[0], b: Awb[1]) B = (w: Bwb[0], b: Bwb[1]) Cw = max(0, C - A.b) A.w -= Cw B.w += Cw A.w += min(D, B.w) echo A.w