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