a, b = 0, 0 for _ in range(4) : x, y = map(int, input().split()) a += (y-x) b = max(b, a) print(b)