#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline long long read() {
  long long x = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return w == 1 ? x : -x;
}
long long n, m, s, dis[1000005];
struct node {
  long long v, w;
};
vector<node> mp[1000005];
struct node2 {
  long long dis, to;
};
inline bool operator<(node2 a, node2 b) { return a.dis > b.dis; }
priority_queue<node2> que;
bool vis[1000005];
long long sx, sy, tx, ty, N, t;
struct node3 {
  long long a, b, id;
} p[1000005];
inline long long D(node3 a, node3 b) { return abs(a.a - b.a) + abs(a.b - b.b); }
inline void A(long long u, long long v, long long w) {
  mp[u].push_back({v, w});
}
inline bool cmp1(node3 a, node3 b) { return a.a < b.a; }
inline bool cmp2(node3 a, node3 b) { return a.b < b.b; }
int main() {
  N = read();
  m = read();
  n = m + 2;
  sx = read();
  sy = read();
  tx = read(), ty = read();
  s = m + 1;
  t = m + 2;
  for (int i = 1; i <= m; i++) p[i].a = read(), p[i].b = read(), p[i].id = i;
  for (int i = 1; i <= m; i++) {
    A(s, i, min(abs(sx - p[i].a), abs(sy - p[i].b)));
    A(i, t, abs(tx - p[i].a) + abs(ty - p[i].b));
  }
  sort(p + 1, p + m + 1, cmp1);
  for (int i = 2; i <= m; i++) {
    A(p[i - 1].id, p[i].id,
      min(abs(p[i].a - p[i - 1].a), abs(p[i].b - p[i - 1].b)));
    A(p[i].id, p[i - 1].id,
      min(abs(p[i].a - p[i - 1].a), abs(p[i].b - p[i - 1].b)));
  }
  sort(p + 1, p + m + 1, cmp2);
  for (int i = 2; i <= m; i++) {
    A(p[i - 1].id, p[i].id,
      min(abs(p[i].a - p[i - 1].a), abs(p[i].b - p[i - 1].b)));
    A(p[i].id, p[i - 1].id,
      min(abs(p[i].a - p[i - 1].a), abs(p[i].b - p[i - 1].b)));
  }
  for (int i = 1; i <= n; i++) dis[i] = 1e18;
  dis[s] = 0;
  que.push((node2){0, s});
  while (!que.empty()) {
    node2 u = que.top();
    que.pop();
    if (vis[u.to]) continue;
    vis[u.to] = 1;
    int uu = u.to;
    for (int i = 0; i < mp[uu].size(); i++) {
      node v = mp[uu][i];
      if (vis[v.v]) continue;
      if (dis[uu] + v.w < dis[v.v]) {
        dis[v.v] = dis[uu] + v.w;
        que.push((node2){dis[v.v], v.v});
      }
    }
  }
  long long ans = abs(sx - tx) + abs(sy - ty);
  cout << min(ans, dis[t]) << endl;
  return 0;
}
