a, b = io.read("*n", "*n") c, d = io.read("*n", "*n") e, f = io.read("*n", "*n") print(math.abs(e + f - c - d))