import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int Aw = sc.nextInt(); final int Ab = sc.nextInt(); final int Bw = sc.nextInt(); final int Bb = sc.nextInt(); final int C = sc.nextInt(); final int D = sc.nextInt(); System.out.println(Aw + Math.min(D - Math.max(0, C - Ab), Bw)); } }