// package question1;

import java.util.Arrays;
import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r =sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int x1=sc.nextInt();
        int y1 = sc.nextInt();
        if((x==x1 && y!=y1) ||(x!=x1 && y==y1)){
            System.out.println(1);
        }
        else if(x==y && x1==y1){
            System.out.println(x1-x);
        }
        else {
            System.out.println(0);
        }
    }
}
