import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int h = sc.nextInt(); int w = sc.nextInt(); int n = sc.nextInt(); Point[] points = new Point[n * 2 + 2]; points[0] = new Point(1, 1); points[1] = new Point(h, w); for (int i = 2; i < n * 2 + 2; i++) { points[i] = new Point(sc.nextInt(), sc.nextInt()); } List> graph = new ArrayList<>(); for (int i = 0; i < n * 2 + 2; i++) { graph.add(new ArrayList<>()); } for (int i = 1; i <= n; i++) { graph.get(i * 2).add(new Path(i * 2 + 1, 1)); for (int j = 1; j <= n; j++) { graph.get(i * 2 + 1).add(new Path(j * 2, points[i * 2 + 1].getDistance(points[j * 2]))); } graph.get(0).add(new Path(i * 2, points[0].getDistance(points[i * 2]))); graph.get(i * 2 + 1).add(new Path(1, points[1].getDistance(points[i * 2 + 1]))); } graph.get(0).add(new Path(1, points[0].getDistance(points[1]))); PriorityQueue queue = new PriorityQueue<>(); queue.add(new Path(0, 0)); long[] costs = new long[n * 2 + 2]; Arrays.fill(costs, Long.MAX_VALUE); while (queue.size() > 0) { Path p = queue.poll(); if (costs[p.idx] <= p.value) { continue; } costs[p.idx] = p.value; for (Path x : graph.get(p.idx)) { queue.add(new Path(x.idx, p.value + x.value)); } } System.out.println(costs[1]); } static class Path implements Comparable { int idx; long value; public Path(int idx, long value) { this.idx = idx; this.value = value; } public int compareTo(Path another) { return Long.compare(value, another.value); } public String toString() { return idx + ":" + value; } } static class Point { int x; int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getDistance(Point p) { return Math.abs(x - p.x) + Math.abs(y - p.y); } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }