import java.io.IOException;
import java.util.Scanner;

public class B {

	static int r;
	static int x0;
	static int y0;
	static int a;
	static int b;

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		Scanner sc = new Scanner(System.in);
		r = sc.nextInt();
		x0 = sc.nextInt();
		y0 = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		System.out.println(count1(a, b, a, b));
	}

	static int count1(int i, int j, int i0, int j0) {
		if (Math.abs(i - x0) > Math.abs(i0 - x0)
				|| Math.abs(j - y0) > Math.abs(j0 - y0))
			return (int) 1e8;
		if ((i == x0 && j == y0) || (i == x0 - r && j == y0)
				|| (i == x0 + r && j == y0) || (i == x0 && j == y0 - r)
				|| (i == x0 && j == y0 + r)) {
			return 0;
		}
		int choice1 = 1 + count2(i - r, j, i, j);
		int choice2 = 1 + count2(i + r, j, i, j);
		int choice3 = 1 + count2(i, j - r, i, j);
		int choice4 = 1 + count2(i, j + r, i, j);

		return Math.min(Math.min(choice1, choice2), Math.min(choice3, choice4));
	}

	static int count2(int i, int j, int i0, int j0) {
		if (Math.abs(i - x0) > Math.abs(i0 - x0)
				|| Math.abs(j - y0) > Math.abs(j0 - y0))
			return (int) 1e8;
		if ((i == x0 && j == y0) || (i == x0 - r && j == y0)
				|| (i == x0 + r && j == y0) || (i == x0 && j == y0 - r)
				|| (i == x0 && j == y0 + r) || (i == x0 + r && j == y0 + r)
				|| (i == x0 + r && j == y0 - r) || (i == x0 - r && j == y0 - r)
				|| (i == x0 - r && j == y0 + r)) {
			return 0;
		}
		int choice1 = 1 + count2(i - r, j, i, j);
		int choice2 = 1 + count2(i + r, j, i, j);
		int choice3 = 1 + count2(i, j - r, i, j);
		int choice4 = 1 + count2(i, j + r, i, j);
		int choice5 = 1 + count2(i - r, j - r, i, j);
		int choice6 = 1 + count2(i + r, j + r, i, j);
		int choice7 = 1 + count2(i - r, j + r, i, j);
		int choice8 = 1 + count2(i + r, j - r, i, j);

		int min;
		min = Math.min(Math.min(choice1, choice2), Math.min(
				Math.min(choice3, choice4), Math.min(choice5, choice6)));
		min = Math.min(min, Math.min(choice7, choice8));
		return min;
	}
}
