#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; int main() { int aw,ab,bw,bb; cin >> aw >> ab >> bw >> bb; int c,d; cin >> c >> d; int ans = aw; c -= ab; if(c > 0) { ans -= c; bw += c; } ans += min(bw,d); cout << ans << endl; return 0; }