#include #include using namespace std; int main() { pair a, b; cin >> a.first >> a.second; cin >> b.first >> b.second; int c, d; cin >> c >> d; if (a.second >= c) { if (d <= b.first) { a.first += d; } else { a.first += b.first; } } else { a.first -= (c - a.second); b.first += (c - a.second); if (d <= b.first) { a.first += d; } else { a.first += b.first; } } cout << a.first << endl; return 0; }