#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c, d, e, f = 0;
  cin >> a >> b >> c >> d >> e;
  a -= c * 2 + d;
  b -= d + e * 3;
  if (a < 0) {
    f += 0 - a;
  }
  if (b < 0) {
    f += 0 - b;
  }
  cout << f;
  return 0;
}
