#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI = acos(-1.0);
template <class T>
inline T _abs(T n) {
  return ((n) < 0 ? -(n) : (n));
}
template <class T>
inline T _max(T a, T b) {
  return (!((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _min(T a, T b) {
  return (((a) < (b)) ? (a) : (b));
}
template <class T>
inline T _swap(T& a, T& b) {
  a = a ^ b;
  b = a ^ b;
  a = a ^ b;
}
template <class T>
inline T gcd(T a, T b) {
  return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template <class T>
inline T lcm(T a, T b) {
  return ((a) / gcd((a), (b)) * (b));
}
long long bigmod(long long a, long long p, long long mod) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = ans * a % mod;
    a = a * a % mod;
    p >>= 1;
  }
  return ans;
}
long long power(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0) {
    long long y = power(x, n / 2);
    return y * y;
  } else
    return x * power(x, n - 1);
}
int bitOn(int N, int pos) { return N = N | (1 << pos); }
int bitOff(int N, int pos) { return N = N & ~(1 << pos); }
bool bitCheck(int N, int pos) { return (bool)(N & (1 << pos)); }
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
int main() {
  long long a, b;
  while (cin >> a >> b) {
    long long x, y, z;
    cin >> x >> y >> z;
    long long needa = 0, needb = 0;
    needa += x * 2;
    needa += y;
    needb += y;
    needb += (z * 3);
    long long tot = 0;
    if (a < needa) tot += (needa - a);
    if (b < needb) tot += (needb - b);
    cout << tot << endl;
  }
  return 0;
}
