#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1 << 30) #define INFLL (1LL << 60) int main() { int aw,ab,bw,bb,e,f; cin >> aw >> ab >> bw >> bb >> e >> f; if(ab > e){ ab -= e; bb += e; }else{ bb += ab; aw -= e-ab; bw += e-ab; ab = 0; } if(bw > f){ aw += f; }else{ aw += bw; } cout << aw << endl; return 0; }