//yukicoder 149 "碁石の移動" //http://yukicoder.me/problems/295 #include using namespace std; int main() { int c, d, aw, ab, bw, bb; cin >> aw >> ab; cin >> bw >> bb; cin >> c >> d; if ( ab >= c) { if (bw >= d) cout << aw + d; else cout << aw + bw; } else { if (bw + c - ab >= d) cout << aw + bw + d - c; else cout << aw + bw; } cout << endl; return 0; }