#include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; int main(){ int Aw, Ab, Bw, Bb, C, D, ans=0; cin >> Aw >> Ab >> Bw >> Bb >> C >> D; ans+=(Aw-C+Ab); if(C-Ab+Bw>D){ ans+=D; } else { ans+=(C-Ab+Bw); } cout << ans << endl; return 0; }