aw, ab = map(int, input().split()) bw, bb = map(int, input().split()) c, d = map(int, input().split()) print(min(aw + bw, aw + d, aw + ab - c + d))