#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m;
int x[N], y[N];
int Calc(int a, int b) { return min(abs(x[a] - x[b]), abs(y[a] - y[b])); }
bool Cmpx(int a, int b) { return x[a] < x[b]; }
bool Cmpy(int a, int b) { return y[a] < y[b]; }
struct Edge {
  int p, nxt, w;
  Edge(int p = 0, int nxt = 0, int w = 0) : p(p), nxt(nxt), w(w) {}
} edge[N * 6];
int tot = -1, head[N];
inline void Add(int u, int v, int w) {
  edge[++tot] = Edge(v, head[u], w);
  head[u] = tot;
  return;
};
int a[N];
int d[N];
struct Node {
  int p, d;
  Node(int p = 0, int d = 0) : p(p), d(d) {}
  bool operator<(const Node &a) const { return d < a.d; }
  bool operator>(const Node &a) const { return d > a.d; }
};
priority_queue<Node, vector<Node>, greater<Node> > pq;
void Dijkstra() {
  for (int i = 0; i <= n + 1; ++i) d[i] = 2E9;
  d[0] = 0;
  pq.push(Node(0, 0));
  while (!pq.empty()) {
    Node cur = pq.top();
    pq.pop();
    int u = cur.p;
    if (d[u] < cur.d) continue;
    for (int i = head[u]; ~i; i = edge[i].nxt) {
      int v = edge[i].p, w = edge[i].w;
      if (d[v] > d[u] + w) pq.push(Node(v, d[v] = d[u] + w));
    }
  }
  return;
}
int main() {
  scanf("%*d%d", &n);
  for (int i = 0; i <= n + 1; ++i) scanf("%d%d", &x[i], &y[i]);
  memset(head, -1, sizeof(head));
  for (int i = 2; i <= n + 1; ++i) Add(0, i, Calc(0, i));
  for (int i = 1; i <= n; ++i) a[i] = i + 1;
  sort(a + 1, a + n + 1, Cmpx);
  for (int i = 1; i < n; ++i) {
    int w = x[a[i + 1]] - x[a[i]];
    Add(a[i], a[i + 1], w);
    Add(a[i + 1], a[i], w);
  }
  sort(a + 1, a + n + 1, Cmpy);
  for (int i = 1; i < n; ++i) {
    int w = y[a[i + 1]] - y[a[i]];
    Add(a[i], a[i + 1], w);
    Add(a[i + 1], a[i], w);
  }
  Dijkstra();
  int ans = abs(x[0] - x[1]) + abs(y[0] - y[1]);
  for (int i = 2; i <= n + 1; ++i)
    ans = min(ans, d[i] + abs(x[i] - x[1]) + abs(y[i] - y[1]));
  printf("%d\n", ans);
  return 0;
}
