#include <bits/stdc++.h>
using namespace std;
long long x, y, z, a, b;
int main() {
  cin >> a >> b >> x >> y >> z;
  long long an = 2 * x + y;
  long long bn = 3 * z + y;
  long long n = 0;
  if (an - a > 0) {
    n += an - a;
  }
  if (bn - b > 0) {
    n += bn - b;
  }
  cout << n;
}
