#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int INF = 0x3f3f3f3f;
int main() {
  long long a, b;
  long long x, y, z;
  cin >> a >> b;
  cin >> x >> y >> z;
  long long t1 = x * 2 + y;
  long long t2 = y + z * 3;
  long long res = 0;
  if (a < t1) res += t1 - a;
  if (b < t2) res += t2 - b;
  cout << res << endl;
}
