#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int aw, ab, bw, bb; cin >> aw >> ab >> bw >> bb; int c, d; cin >> c >> d; int x; x = min(ab, c); ab -= x; aw -= c - x; bw += c - x; bb += c; cout << aw + min(bw, d) << '\n'; return 0; }