import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int aw, ab, bw, bb, x, y; aw = sc.nextInt(); ab = sc.nextInt(); bw = sc.nextInt(); bb = sc.nextInt(); x = sc.nextInt(); y = sc.nextInt(); bw += Math.max(0, x - ab); aw -= Math.max(0, x - ab); aw += Math.min(y, bw); System.out.println(aw); } }