#include <bits/stdc++.h>
using namespace std;
signed main(){
int a,b,c,d,m; cin>>a>>b>>c>>d>>m;
if(c*5-(a-c)*5<=m){
if((c*5-(a-c)*5)-(b-d)*20<=0) cout<<"0";
else cout<<(c*5-(a-c)*5)-((b-d)*20);
}else{
if(((c*5-(a-c)*5)+(d*20-(b-d)*20))<=0) cout<<"0";
else cout<<(c*5-(a-c)*5)+(d*20-(b-d)*20);
}
return 0;
}