#include using namespace std; int main(void) { int aw, ab, bw, bb, c, d; cin >> aw >> ab >> bw >> bb >> c >> d; //move only black stones as many as possible int first = min(ab, c); c -= first; int second = min(aw, c); aw -= second; bw += second; //move only white stones int third = min(bw, d); aw += third; cout << aw << endl; return 0; }