#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b;
  cin >> a >> b;
  long long int yellow, green, blue;
  cin >> yellow;
  a = a - 2 * yellow;
  cin >> green;
  a = a - green;
  b = b - green;
  cin >> blue;
  b = b - 3 * blue;
  long long int sum = 0;
  a < 0 ? sum += abs(a) : sum += 0;
  b < 0 ? sum += abs(b) : sum += 0;
  cout << sum << endl;
  return 0;
}
