from sys import stdin def main(): input = lambda: stdin.readline()[:-1] R, C = map(int, input().split()) SY, SX = map(int, input().split()) GY, GX = map(int, input().split()) C_ = stdin.read().splitlines() print(GY - SY + GX - SX) main()