#include #include using namespace std; int main(){ int a,b,c,d,e,f; scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f); int ret=a; ret-=max(0,e-b); c+=max(0,e-b); ret+=min(f,c); printf("%d\n",ret); }