#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, x, y, z, c = 0, ye = 0, bl = 0;
  scanf("%lld%lld%lld%lld%lld", &n, &m, &x, &y, &z);
  ye += 2 * x;
  ye += y;
  bl += y;
  bl += 3 * z;
  if (ye > n) c += ye - n;
  if (bl > m) c += bl - m;
  cout << c << endl;
  return 0;
}
