import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int Aw = scan.nextInt(); int Ab = scan.nextInt(); int Bw = scan.nextInt(); int Bb = scan.nextInt(); int C = scan.nextInt(); int D = scan.nextInt(); scan.close(); if(C >= Ab) { int w = C - Ab; int b = Ab; Aw = Aw - w; Bw = Bw + w; Bb = Bb + b; if(D <= Bw) { Aw = Aw + D; }else { Aw = Aw + Bw; } }else { int b = C; Bb = Bb + b; if(D <= Bw) { Aw = Aw + D; }else { Aw = Aw + Bw; } } System.out.println(Aw); } }