import strutils, sequtils let Awb, Bwb, CD = stdin.readLine.split.map parseInt (C, D) = (CD[0], CD[1]) var (Aw, Ab) = (Awb[0], Awb[1]) (Bw, Bb) = (Bwb[0], Bwb[1]) Cw = max(0, C - Ab) Aw -= Cw Bw += Cw Aw += min(D, Bw) echo Aw