#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; int Aw, Ab, Bw, Bb, C, D; ll ans; int main() { cin >> Aw >> Ab >> Bw >> Bb >> C >> D; ans = Aw; if (C > Ab) { ans -= C - Ab; Bw += C - Ab; } if (D < Bw) { ans += Bw-(Bw - D); } else ans += Bw; cout << ans << endl; return 0; }