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