#include using namespace std; int main() { int Aw, Ab, Bw, Bb, C, D; cin >> Aw >> Ab >> Bw >> Bb >> C >> D; while (C--) { if (Ab) Ab--, Bb++; else Aw--, Bw++; } while (D--) { if (Bw) Bw--, Aw++; } cout << Aw << endl; }