#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
using llong = long long;
using ld = long double;
using itn = int;
using ii = pair<int, int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
using psi = pair<string, int>;
using ll = pair<llong, llong>;
const llong over999 = 1e9;
const ld over999ld = 1e18 + 1;
const llong md = 1e9 + 7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
const llong nich = 0;
const int mnogo = 300;
llong x, y, a, b, c;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> x >> y;
  cin >> a >> b >> c;
  llong A = a * 2 + b;
  llong B = c * 3 + b;
  cout << max(0LL, A - x) + max(0LL, B - y);
  return 0;
}
