#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
using namespace std;
const int MAXN = 1000005;
const int MAXM = 50005;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
void debug_out() { cerr << endl; }
template <typename T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
int n, m;
int sx, sy, ex, ey;
long long dis[MAXN];
int vis[MAXN];
int x[MAXN], y[MAXN];
int xx[MAXN], yy[MAXN];
struct Edge {
  int to;
  long long w;
  int nxt;
} edge[MAXN << 1];
struct E {
  int to;
  long long w;
  bool operator<(const E& x) const { return w > x.w; }
};
int tot = 1, head[MAXN];
inline void add_edge(int u, int v, long long w) {
  edge[++tot].to = v;
  edge[tot].w = w;
  edge[tot].nxt = head[u];
  head[u] = tot;
  edge[++tot].to = u;
  edge[tot].w = w;
  edge[tot].nxt = head[v];
  head[v] = tot;
}
long long dij(int s, int e) {
  for (int i = (0); i <= (e); i++) dis[i] = 1e18;
  priority_queue<E> q;
  q.push({s, 0});
  dis[s] = 0;
  while (!q.empty()) {
    E u = q.top();
    q.pop();
    if (vis[u.to]) continue;
    vis[u.to] = 1;
    for (int i = head[u.to]; i; i = edge[i].nxt) {
      int v = edge[i].to;
      if (dis[u.to] + edge[i].w < dis[v]) {
        dis[v] = dis[u.to] + edge[i].w;
        q.push({v, dis[v]});
      }
    }
  }
  return dis[e];
}
void solve() {
  cin >> n >> m;
  cin >> sx >> sy >> ex >> ey;
  int st = 0, ed = 3 * m + 1;
  add_edge(st, ed, abs(sx - ex) + abs(sy - ey));
  for (int i = (1); i <= (m); i++) {
    cin >> x[i] >> y[i];
    xx[i] = x[i], yy[i] = y[i];
  }
  sort(xx + 1, xx + m + 1);
  sort(yy + 1, yy + m + 1);
  for (int i = (2); i <= (m); i++) {
    add_edge(m + i - 1, m + i, xx[i] - xx[i - 1]);
    add_edge(2 * m + i - 1, 2 * m + i, yy[i] - yy[i - 1]);
  }
  for (int i = (1); i <= (m); i++) {
    int idx = lower_bound(xx + 1, xx + m + 1, x[i]) - xx;
    int idy = lower_bound(yy + 1, yy + m + 1, y[i]) - yy;
    add_edge(i, m + idx, 0);
    add_edge(i, 2 * m + idy, 0);
    add_edge(st, m + idx, min(abs(x[i] - sx), abs(y[i] - sy)));
    add_edge(m + idx, ed, abs(x[i] - ex) + abs(y[i] - ey));
  }
  cout << dij(st, ed) << endl;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
