#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  T s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + ch - 48;
    ch = getchar();
  }
  return s * f;
}
constexpr int mod = 1e9 + 7;
constexpr int N = 2e5 + 100;
const int maxn = 2e6 + 100;
int head[maxn], tot = 0;
struct node {
  int to, net;
  long long w;
} s[maxn];
struct Point {
  int x, y, id;
} v[N];
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void add(int now, int to, int w) {
  s[++tot] = {to, head[now], (long long)w};
  head[now] = tot;
}
long long dis[N];
void dij(int S) {
  memset(dis, 0x3f, sizeof(dis));
  dis[S] = 0;
  priority_queue<pair<long long, int> > q;
  q.push({0, S});
  while (!q.empty()) {
    if (-q.top().first > dis[q.top().second]) {
      q.pop();
      continue;
    }
    int now = q.top().second;
    q.pop();
    for (int i = head[now]; ~i; i = s[i].net) {
      int to = s[i].to;
      if (dis[to] > dis[now] + s[i].w) {
        dis[to] = dis[now] + s[i].w;
        q.push({-dis[to], to});
      }
    }
  }
}
int main() {
  init();
  Point start, end;
  int n = read<int>(), m = read<int>();
  start.x = read<int>(), start.y = read<int>();
  end.x = read<int>(), end.y = read<int>();
  for (int i = 1; i <= m; ++i) {
    v[i] = {read<int>(), read<int>(), i};
  }
  int S = 0, T = m + 1;
  add(S, T, abs(start.x - end.x) + abs(start.y - end.y));
  for (int i = 1; i <= m; ++i) {
    add(S, i, min(abs(start.x - v[i].x), abs(start.y - v[i].y)));
    add(i, T, abs(end.x - v[i].x) + abs(end.y - v[i].y));
  }
  sort(v + 1, v + 1 + m, [](Point left, Point right) {
    if (left.y == right.y) return left.x < right.x;
    return left.y < right.y;
  });
  for (int i = 2; i <= m; ++i) {
    add(v[i - 1].id, v[i].id,
        min(abs(v[i - 1].x - v[i].x), abs(v[i - 1].y - v[i].y)));
    add(v[i].id, v[i - 1].id,
        min(abs(v[i - 1].x - v[i].x), abs(v[i - 1].y - v[i].y)));
  }
  sort(v + 1, v + 1 + m, [](Point left, Point right) {
    if (left.x == right.x) return left.y < right.y;
    return left.x < right.x;
  });
  for (int i = 2; i <= m; ++i) {
    add(v[i - 1].id, v[i].id,
        min(abs(v[i - 1].x - v[i].x), abs(v[i - 1].y - v[i].y)));
    add(v[i].id, v[i - 1].id,
        min(abs(v[i - 1].x - v[i].x), abs(v[i - 1].y - v[i].y)));
  }
  dij(S);
  cout << dis[T] << endl;
}
