During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.

Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow crystals, green — one yellow and one blue, and for a blue ball, three blue crystals are enough.

Right now there are A yellow and B blue crystals in Grisha's disposal. Find out how many additional crystals he should acquire in order to produce the required number of balls.


-----Input-----

The first line features two integers A and B (0 ≤ A, B ≤ 10^9), denoting the number of yellow and blue crystals respectively at Grisha's disposal.

The next line contains three integers x, y and z (0 ≤ x, y, z ≤ 10^9) — the respective amounts of yellow, green and blue balls to be obtained.


-----Output-----

Print a single integer — the minimum number of crystals that Grisha should acquire in addition.


-----Examples-----
Input
4 3
2 1 1

Output
2

Input
3 9
1 1 3

Output
1

Input
12345678 87654321
43043751 1000000000 53798715

Output
2147483648



-----Note-----

In the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue.

Difficulty: interview

Starter code:

Solutions:
#!/usr/bin/env python3

def main():
    a, b = list(map(int, input().split()))
    x, y, z = list(map(int, input().split()))
    print(max(x * 2 + y - a, 0) + max(y + z * 3 - b, 0))

try:
    while True:
        main()
except EOFError:
    pass


a, b = map(int, input().split())
x, y, z = map(int, input().split())
yo = max(0, x * 2 + y - a)
oy = max(0, y + z * 3 - b)
print(yo + oy)

import math
a, b = map(int, input().split())
x, y, z = map(int, input().split())

r = 2 * x + y
t = y + 3 * z
print(max(0, r - a) + max(0, t - b))

R=lambda:list(map(int,input().split()))
a,b=R()
x,y,z=R()
print(max(0,2*x+y-a)+max(0,y+3*z-b))


# map(int, input().split())
# list(map(int, input().split()))
A, B = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))
need_a = 2 * x + 1 * y + 0 * z
need_b = 1 * y + 3 * z
print(max(0, need_a - A) + max(0, need_b - B))
            


a, b = map(int, input().split())
x, y, z = map(int, input().split())
a1, b1 = x * 2 + y, z * 3 + y
print(max(a1 - a, 0) + max(b1 - b, 0))

a,b=map(int,input().split(' '))
x,y,z=map(int,input().split(' '))
ans=max(0,2*x+y-a)+max(0,y+3*z-b)
print(ans)

from sys import stdin, stdout

A,B = list(map(int, stdin.readline().rstrip().split()))

x,y,z = list(map(int, stdin.readline().rstrip().split()))

A-=2*x
A-=y
B-=y
B-=3*z

crystals=0
if A<0:
    crystals+=-A
if B<0:
    crystals+=-B
    
print(crystals)




a, b = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))

c = 2 * x + y
d = y + 3 * z

print(max(c - a, 0) + max(d - b, 0))


y,b=map(int,input().split())
A=list(map(int,input().split()))
yn=2*A[0]+A[1]
bn=A[1]+3*A[2]
ym=max(0,yn-y)
bm=max(0,bn-b)
print(ym+bm)

a, b = [int(i) for i in input().split()]
x, y, z = [int(i) for i in input().split()]
ans = 0
if b - (z * 3 + y) < 0:    
    ans += b - (z * 3 + y)
if a - (2 * x + y) < 0:
    ans += a - (2 * x + y)
print(abs(ans))

a, b = [int(v) for v in input().split()]
x, y, z = [int(v) for v in input().split()]

ra = 2*x + y
rb = y + 3*z

print(max(ra - a, 0) + max(rb - b, 0))


A, B = list(map(int, input().split()))
x,y,z = list(map(int, input().split()))

A -= x*2
A -= y
B -= y
B -= 3*z

if A>0:
    A = 0
if B>0:
    B = 0
print(abs(A+B))


A, B = list(map(int, input().split()))
x, y, z = list(map(int, input().split()))

a, b = 0, 0

a += 2 * x
a += y
b += y
b += 3 * z

print(max(0, a - A) + max(0, b - B))


#!/usr/bin/env python3
#! -*- coding: utf-8 -*-


def main():
	a, b = map(int, input().split())
	x, y, z = map(int, input().split())
	need_y = x * 2 + y
	need_b = 3 * z + y
	print(max(0, need_y - a) + max(0, need_b - b))


def __starting_point():
	main()
__starting_point()

import sys

def main():
    yellow_crystals, blue_crystals = list(map(int, input().split()))
    yellow, green, blue = list(map(int, input().split()))
    
    yellow_req = yellow * 2 + green
    blue_req = green + blue * 3
    
    print(max(0, yellow_req - yellow_crystals) + max(0, blue_req - blue_crystals))
    
	
def __starting_point():
    main() 
    

__starting_point()

R=lambda:list(map(int,input().split()))
a,b=R()
x,y,z=R()
A=x+x+y
B=y+3*z
print(max(0,A-a)+max(0,B-b))


a, b = map(int, input().split())
x, y, z = map(int, input().split())

print(max(0, 2 * x + y - a) + max(0, y + 3 * z - b))

A, B = map(int, input().split())
x, y, z = map(int, input().split())
nem = x * 2 + y
nes = z * 3 + y
print(max(nem - A, 0) + max(nes - B, 0))

zlu,blu = map(int,input().split())
x,y,z = map(int,input().split())
zl = 2*x+y
bl = 3*z+y
if zl >zlu:
    dif1 = zl - zlu
else:
    dif1 = 0
if bl >blu:
    dif2 = bl - blu
else:
    dif2 = 0
print(dif1+dif2)

a, b = [int(i) for i in input().split()]
x, y, z = [int(i) for i in input().split()]
a -= 2 * x
a -= y
b -= y
b -= 3 * z
ans = 0
if a < 0:
    ans -= a
if b < 0:
    ans -= b
print(ans)


a,b=tuple(map(int, input().split()))
x,y,z=tuple(map(int, input().split()))
print(max(2*x+y-a,0)+max(y+3*z-b,0))


a,b = list(map(int, input().split()))
z, x, y = list(map(int, input().split()))
A = z * 2 + x
B = 3 * y + x
print(max(0, A - a) + max(0, B - b))


def read():
    return list(map(int,input().split()))
a,b=read()
x,y,z=read()
a-=2*x+y
b-=3*z+y
s=0
if a<0:
    s-=a
if b<0:
    s-=b
print(s)


A,B = list(map(int, input().split(' ')))
x, y, z = list(map(int, input().split(' ')))

y_needed = max(0, x*2 + y - A)
b_needed = max(0, y + 3*z - B)

print(y_needed + b_needed)