#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, inf = 0x3f3f3f3f;
int n, sx, sy, fx, fy;
int m, head[N], tot, dist[N], vis[N];
template <class T>
void read(T &x) {
  T res = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  x = res * f;
}
struct node {
  int x, y;
  int id;
} p[N];
struct edge {
  int x, y, net;
  int z;
} e[N << 3];
bool cmp1(node a, node b) {
  if (a.x != b.x)
    return a.x < b.x;
  else
    return a.y < b.y;
}
bool cmp2(node a, node b) {
  if (a.y != b.y)
    return a.y < b.y;
  else
    return a.x < b.x;
}
void add(int x, int y, int z) {
  e[++tot].y = y, e[tot].z = z, e[tot].net = head[x], head[x] = tot;
}
void add_double(int x, int y, int z) {
  add(x, y, z);
  add(y, x, z);
}
int dij(int s, int t) {
  for (int i = 0; i <= t; i++) {
    dist[i] = inf;
    vis[i] = 0;
  }
  priority_queue<pair<int, int> > q;
  dist[s] = 0;
  q.push({dist[s], s});
  while (q.size()) {
    auto u = q.top();
    q.pop();
    int x = u.second;
    if (vis[x]) continue;
    vis[x] = 1;
    for (int i = head[x]; i; i = e[i].net) {
      int y = e[i].y, z = e[i].z;
      if (dist[y] > dist[x] + z) {
        dist[y] = dist[x] + z;
        q.push({-dist[y], y});
      }
    }
  }
  return dist[t];
}
void solve() {
  read(n), read(m);
  read(sx), read(sy), read(fx), read(fy);
  int ans = abs(sx - fx) + abs(sy - fy);
  if (m == 0)
    printf("%d\n", ans);
  else {
    int s = 0, t = m + 1;
    for (int i = 1; i <= m; i++) {
      read(p[i].x);
      read(p[i].y);
      p[i].id = i;
      int w1 = p[i].x == sx ? 0 : abs(p[i].x - sx);
      int w2 = p[i].y == sy ? 0 : abs(p[i].y - sy);
      int w3 = abs(p[i].x - fx) + abs(p[i].y - fy);
      add(s, i, w1);
      add(s, i, w2);
      add(i, t, w3);
    }
    sort(p + 1, p + 1 + m, cmp1);
    for (int i = 2; i <= m; i++) {
      int u = p[i - 1].id;
      int v = p[i].id;
      int w = p[i - 1].y == p[i].y ? 0 : abs(p[i - 1].x - p[i].x);
      add_double(u, v, w);
    }
    sort(p + 1, p + 1 + m, cmp2);
    for (int i = 2; i <= m; i++) {
      int u = p[i - 1].id;
      int v = p[i].id;
      int w = p[i - 1].x == p[i].x ? 0 : abs(p[i - 1].y - p[i].y);
      add_double(u, v, w);
    }
    ans = min(ans, dij(s, t));
    printf("%d\n", ans);
  }
}
int main() {
  solve();
  return 0;
}
