#include using namespace std; int main(int argc, const char * argv[]) { int Aw,Ab,Bw,Bb,C,D; cin >> Aw >> Ab; cin >> Bw >> Bb; cin >> C >> D; if(C <= Ab){ Ab-=C; Bb+=C; } else{ Aw -= C-Ab; Bb += Ab; Bw += C-Ab; } if (D <= Bw) { Aw += D; } else{ Aw += Bw; } cout << Aw << endl; return 0; }