#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct edge {
  int y, w, next;
} data[N * 8];
struct node {
  int x, y, id;
} a1[N];
struct dist {
  int id;
  long long dis;
  inline bool operator<(const dist& y) const { return dis > y.dis; }
} d1[N];
int n, m, sx, sy, tx, ty, vis[N], num, h[N];
priority_queue<dist> q;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x;
}
inline void addedge(int u, int v, int w) {
  data[++num].y = v, data[num].w = w, data[num].next = h[u], h[u] = num;
  data[++num].y = u, data[num].w = w, data[num].next = h[v], h[v] = num;
}
inline int min1(int i, int j) { return i < j ? i : j; }
bool cmp1(node i, node j) { return i.x < j.x; }
bool cmp2(node i, node j) { return i.y < j.y; }
int main() {
  n = read(), m = read();
  sx = read(), sy = read(), tx = read(), ty = read();
  memset(h, -1, sizeof h);
  num = 0;
  addedge(m + 1, m + 2, abs(sx - tx) + abs(sy - ty));
  for (int i = 1; i <= m; ++i)
    a1[i].x = read(), a1[i].y = read(), a1[i].id = i,
    addedge(m + 1, i, min1(abs(a1[i].x - sx), abs(a1[i].y - sy))),
    addedge(m + 2, i, abs(a1[i].x - tx) + abs(a1[i].y - ty));
  sort(a1 + 1, a1 + m + 1, cmp1);
  for (int i = 2; i <= m; ++i)
    addedge(a1[i].id, a1[i - 1].id, a1[i].x - a1[i - 1].x);
  sort(a1 + 1, a1 + m + 1, cmp2);
  for (int i = 2; i <= m; ++i)
    addedge(a1[i].id, a1[i - 1].id, a1[i].y - a1[i - 1].y);
  for (int i = 1; i <= m + 2; ++i) d1[i].dis = 1e10, d1[i].id = i;
  memset(vis, 0, sizeof vis);
  d1[m + 1].dis = 0;
  while (!q.empty()) q.pop();
  q.push(d1[m + 1]);
  while (!q.empty()) {
    dist u = q.top();
    q.pop();
    vis[u.id] = 1;
    if (u.id == m + 2) break;
    for (int i = h[u.id], v; i != -1; i = data[i].next) {
      v = data[i].y;
      if (vis[v]) continue;
      if (d1[v].dis > u.dis + data[i].w) {
        d1[v].dis = u.dis + data[i].w;
        q.push(d1[v]);
      }
    }
  }
  printf("%d", d1[m + 2].dis);
  return 0;
}
