#include <bits/stdc++.h>
using namespace std;
void tempwj() {
  freopen("hash.in", "r", stdin);
  freopen("hash.out", "w", stdout);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long qpow(long long a, long long b, long long mod) {
  a %= mod;
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
struct cmp {
  bool operator()(const pair<int, long long>& a,
                  const pair<int, long long>& b) {
    return a.second > b.second;
  }
};
int lb(int x) { return x & -x; }
const int inf = INT_MAX;
const double esp = 1e-6;
const long long INF = 0x3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 6;
int id[maxn];
pair<int, long long> pp[maxn];
bool cmp1(int a, int b) { return pp[a].first < pp[b].first; }
bool cmp2(int a, int b) { return pp[a].second < pp[b].second; }
struct Edge {
  int id, val, nex;
} edge[maxm << 1];
int head[maxn];
int cnt;
void add(int x, int y, int val) {
  edge[cnt].id = y;
  edge[cnt].val = val;
  edge[cnt].nex = head[x];
  head[x] = cnt++;
}
long long dis[maxn];
int vis[maxn];
priority_queue<pair<int, long long>, vector<pair<int, long long> >, cmp> qq;
void dj(int s) {
  dis[s] = 0;
  qq.push(make_pair(s, 0));
  while (!qq.empty()) {
    pair<int, long long> t = qq.top();
    qq.pop();
    int x = t.first;
    if (vis[x]) continue;
    vis[x] = 1;
    for (int i = head[x]; ~i; i = edge[i].nex) {
      int v = edge[i].id;
      if (vis[v] == 0 && dis[v] > dis[x] + edge[i].val) {
        dis[v] = dis[x] + edge[i].val;
        qq.push(make_pair(v, dis[v]));
      }
    }
  }
}
int main() {
  cnt = 0;
  int n, m;
  scanf("%d%d", &n, &m);
  int sx, sy, ex, ey;
  scanf("%d%d%d%d", &sx, &sy, &ex, &ey);
  for (int i = 1; i <= m; i++) {
    scanf("%d%lld", &pp[i].first, &pp[i].second);
    id[i] = i;
  }
  int s = m + 1;
  int t = m + 2;
  for (int i = 0; i <= t; i++) head[i] = -1;
  sort(id + 1, id + 1 + m, cmp1);
  for (int i = 1; i < m; i++) {
    add(id[i], id[i + 1], abs(pp[id[i]].first - pp[id[i + 1]].first));
    add(id[i + 1], id[i], abs(pp[id[i]].first - pp[id[i + 1]].first));
  }
  sort(id + 1, id + 1 + m, cmp2);
  for (int i = 1; i < m; i++) {
    add(id[i], id[i + 1], abs(pp[id[i]].second - pp[id[i + 1]].second));
    add(id[i + 1], id[i], abs(pp[id[i]].second - pp[id[i + 1]].second));
  }
  add(s, t, abs(sx - ex) + abs(sy - ey));
  for (int i = 1; i <= m; i++) {
    add(s, i, min(1ll * abs(sx - pp[i].first), abs(sy - pp[i].second)));
    add(i, t, abs(pp[i].first - ex) + abs(pp[i].second - ey));
  }
  for (int i = 1; i <= m + 2; i++) {
    dis[i] = INF;
  }
  dj(s);
  printf("%lld\n", dis[t]);
}
