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