#include <bits/stdc++.h>
using namespace std;
int dX1[4] = {0, 0, -1, 1};
int dY1[4] = {-1, 1, 0, 0};
int dX2[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dY2[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
const int MOD = 1000000007;
const int mxn = 2e5;
const int INF = 2e9;
int n, m;
int sx, sy, fx, fy;
int x[mxn], y[mxn], d[mxn];
int mult(int a, int b) { return (1LL * a * b) % MOD; }
int add(int a, int b) {
  long long res = 0LL + a + b;
  while (res >= MOD) {
    res -= MOD;
  }
  while (res < 0) {
    res += MOD;
  }
  return res;
}
int sub(int a, int b) {
  long long res = 0LL + a - b;
  while (res >= MOD) {
    res -= MOD;
  }
  while (res < 0) {
    res += MOD;
  }
  return res;
}
int exp(int x, int n) {
  if (n == 0) {
    return 1;
  }
  if (n == 1) {
    return x;
  }
  int ret = exp(x, n >> 1);
  if (n & 1) {
    return mult(mult(ret, ret), x);
  }
  return mult(ret, ret);
}
int divd(int a, int b) {
  int inv = exp(b, MOD - 2);
  return mult(a, inv);
}
int main() {
  cin >> n >> m;
  cin >> sx >> sy >> fx >> fy;
  x[0] = sx;
  y[0] = sy;
  d[0] = 0;
  for (int i = 1; i <= m; i++) {
    cin >> x[i] >> y[i];
    d[i] = INF;
  }
  vector<pair<pair<int, int>, int>> ox, oy;
  for (int i = 0; i <= m; i++) {
    ox.push_back(make_pair(make_pair(x[i], y[i]), i));
    oy.push_back(make_pair(make_pair(y[i], x[i]), i));
  }
  sort(ox.begin(), ox.end());
  sort(oy.begin(), oy.end());
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  pq.push(make_pair(0, 0));
  while (!pq.empty()) {
    pair<int, int> cur = pq.top();
    pq.pop();
    int dst = cur.first;
    int idx = cur.second;
    assert(dst >= d[idx]);
    if (dst > d[idx]) continue;
    {
      int pos = lower_bound(ox.begin(), ox.end(),
                            make_pair(make_pair(x[idx], y[idx]), idx)) -
                ox.begin();
      if (pos > 0) {
        int j = ox[pos - 1].second;
        int nd = d[idx] + abs(x[j] - x[idx]);
        if (nd < d[j]) {
          d[j] = nd;
          pq.push(make_pair(d[j], j));
        }
      }
      if (pos + 1 <= m) {
        int j = ox[pos + 1].second;
        int nd = d[idx] + abs(x[j] - x[idx]);
        if (nd < d[j]) {
          d[j] = nd;
          pq.push(make_pair(d[j], j));
        }
      }
    }
    {
      int pos = lower_bound(oy.begin(), oy.end(),
                            make_pair(make_pair(y[idx], x[idx]), idx)) -
                oy.begin();
      if (pos > 0) {
        int j = oy[pos - 1].second;
        int nd = d[idx] + abs(y[j] - y[idx]);
        if (nd < d[j]) {
          d[j] = nd;
          pq.push(make_pair(d[j], j));
        }
      }
      if (pos + 1 <= m) {
        int j = oy[pos + 1].second;
        int nd = d[idx] + abs(y[j] - y[idx]);
        if (nd < d[j]) {
          d[j] = nd;
          pq.push(make_pair(d[j], j));
        }
      }
    }
  }
  int ans = INF;
  for (int i = 0; i <= m; i++) {
    ans = min(ans, d[i] + abs(y[i] - fy) + abs(x[i] - fx));
  }
  cout << ans << endl;
}
