#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  return x * f;
}
const int maxn = 1e5 + 5;
long long n, m, sx, sy, fx, fy, x[maxn], y[maxn];
long long ans, vis[maxn], mp[maxn], dis[maxn];
struct point {
  long long x, y, id;
} p[maxn], t[maxn];
bool cmp1(point a, point b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool cmp2(point a, point b) {
  if (a.y != b.y) return a.y < b.y;
  return a.x < b.x;
}
struct node {
  long long id, dis;
  bool operator<(const node a) const { return dis > a.dis; }
};
long long calc(long long a, long long b, long long c, long long d) {
  return min(abs(a - c), abs(b - d));
}
void dij() {
  priority_queue<node> q;
  int d = 0;
  for (int i = 1; i <= m; i++) {
    dis[i] = min(abs(p[i].x - sx), abs(p[i].y - sy));
    q.push({i, dis[i]});
  }
  while (!q.empty()) {
    node e1 = q.top();
    q.pop();
    if (vis[e1.id]) continue;
    vis[e1.id] = 1;
    int pos = e1.id - 1;
    if (pos != 0) {
      if (dis[pos] >
          dis[pos + 1] + calc(p[pos].x, p[pos].y, p[pos + 1].x, p[pos + 1].y)) {
        dis[pos] =
            dis[pos + 1] + calc(p[pos].x, p[pos].y, p[pos + 1].x, p[pos + 1].y);
        q.push({pos, dis[pos]});
      }
    }
    pos = e1.id;
    if (pos != m) {
      if (dis[pos + 1] >
          dis[pos] + calc(p[pos].x, p[pos].y, p[pos + 1].x, p[pos + 1].y)) {
        dis[pos + 1] =
            dis[pos] + calc(p[pos].x, p[pos].y, p[pos + 1].x, p[pos + 1].y);
        q.push({pos + 1, dis[pos + 1]});
      }
    }
    pos = mp[e1.id] - 1;
    if (pos != 0) {
      if (dis[t[pos].id] >
          dis[t[pos + 1].id] +
              calc(t[pos].x, t[pos].y, t[pos + 1].x, t[pos + 1].y)) {
        dis[t[pos].id] = dis[t[pos + 1].id] +
                         calc(t[pos].x, t[pos].y, t[pos + 1].x, t[pos + 1].y);
        q.push({t[pos].id, dis[t[pos].id]});
      }
    }
    pos = mp[e1.id];
    if (pos != m) {
      if (dis[t[pos + 1].id] >
          dis[t[pos].id] +
              calc(t[pos].x, t[pos].y, t[pos + 1].x, t[pos + 1].y)) {
        dis[t[pos + 1].id] = dis[t[pos].id] + calc(t[pos].x, t[pos].y,
                                                   t[pos + 1].x, t[pos + 1].y);
        q.push({t[pos + 1].id, dis[t[pos + 1].id]});
      }
    }
  }
}
int main() {
  n = rd();
  m = rd();
  p[0].x = -1e9;
  p[0].y = -1e9;
  sx = rd();
  sy = rd();
  fx = rd();
  fy = rd();
  for (int i = 1; i <= m; i++) {
    p[i].x = rd();
    p[i].y = rd();
  }
  ans = abs(sx - fx) + abs(sy - fy);
  sort(p + 1, p + m + 1, cmp1);
  for (int i = 1; i <= m; i++) {
    p[i].id = i;
    t[i] = p[i];
  }
  sort(t + 1, t + m + 1, cmp2);
  for (int i = 1; i <= m; i++) mp[t[i].id] = i;
  dij();
  for (int i = 1; i <= m; i++)
    ans = min(ans, dis[i] + abs(p[i].x - fx) + abs(p[i].y - fy));
  printf("%lld\n", ans);
  return 0;
}
