package dongtai;
import java.util.Scanner;
public class chonhQi {
public static int[] Gas_min=new int[1000];
public static int chongMinGas=0;
public static int tempGas=0;
public static int testcase=5;
public static int min_res=0;
public static int min_resu[]=new int[1000];
public static int pc=0;
public static int[] chong=new int[5];
public static int[] fang=new int[5];
public static int flag[]=new int[5];
public static int aa[]=new int[5];
public static int bb[]=new int[5];
public static int minGas(int cho[],int fan[]){
int length=cho.length;
for(int i=0;i<length;i++){
if(tempGas+cho[i]-fan[i]>0){
tempGas+=cho[i]-fan[i];
}
if(tempGas+cho[i]-fan[i]<0){
chongMinGas+=tempGas+fan[i]-cho[i];
tempGas+=tempGas+cho[i]-fan[i];
System.out.println(chongMinGas);
}
}
return chongMinGas;
}
public static boolean zhonfu(int n){
boolean res=true;
for(int i=0;i<testcase;i++){
if(flag[i]==n)
res=false;
}
return res;
}
public static void gas_DFS(int n){
if(testcase==n){
for(int i=0;i<testcase;i++){
aa[i]=chong[flag[i]];
bb[i]=fang[flag[i]];
}
min_resu[pc++]=minGas(aa,bb);
return;
}
for(int i=0;i<testcase;i++){
if(zhonfu(i)){
flag[i]=i;
gas_DFS(n+1);
flag[i]=-1;
}
}
}
public static void main(String[] args){
int pc=0;
Scanner in=new Scanner(System.in);
//int testcase=in.nextInt();
while(in.hasNext()){
/* if(pc==testcase+1){
break;
}
//pc++;*/
int n=in.nextInt();
int limit=in.nextInt();
for(int i=0;i<n;i++){
chong[i]=in.nextInt();
}
for(int i=0;i<n;i++){
fang[i]=in.nextInt();
}
System.out.print( minGas(chong,fang));
// for(int i=0;i<testcase;i++){
// fang[i]=-1;
// }
/*gas_DFS(0);
min_res=min_resu[0];
for(int k=1;k<pc;k++){
if(min_res>min_resu[k]){
min_res=min_resu[k];
}
}*/
}
//System.out.print(min_res);
}
}