#include <bits/stdc++.h>
using namespace std;
long long n, m, cnt;
long long a, b, c;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  cin >> a >> b >> c;
  a *= 2;
  c *= 3;
  a += b;
  c += b;
  if (n - a < 0) {
    cnt += abs(n - a);
  }
  if (m - c < 0) {
    cnt += abs(m - c);
  }
  cout << cnt;
}
