a, b, c, d = map(int, input().split()) p, q = abs(c - a), abs(d - b) ans = min((p + q + 2) // 3, 1 + (min(p, q) + 2) // 3, 2) print(ans)