#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void mad(long long &a, long long b) {
  a = (a + b) % 1000000007;
  if (a < 0) a += 1000000007;
}
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
bool fun(tuple<int, int, int> a, tuple<int, int, int> b) {
  int x1, y1, u, x2, y2, v;
  tie(x1, y1, u) = a;
  tie(x2, y2, v) = b;
  if (y1 == y2) return x1 < x2;
  return y1 < y2;
}
void solve() {
  int n, m;
  cin >> n >> m;
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  vector<pair<int, int> > ed[m];
  vector<tuple<int, int, int> > p;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    p.push_back(make_tuple(x, y, i));
  }
  sort(p.begin(), p.end());
  for (int i = 0; i + 1 < m; i++) {
    int x1, y1, u, x2, y2, v;
    tie(x1, y1, u) = p[i];
    tie(x2, y2, v) = p[i + 1];
    int d = min(abs(x1 - x2), abs(y1 - y2));
    ed[u].push_back(pair<int, int>(v, d));
    ed[v].push_back(pair<int, int>(u, d));
  }
  sort(p.begin(), p.end(), fun);
  for (int i = 0; i + 1 < m; i++) {
    int x1, y1, u, x2, y2, v;
    tie(x1, y1, u) = p[i];
    tie(x2, y2, v) = p[i + 1];
    int d = min(abs(x1 - x2), abs(y1 - y2));
    ed[u].push_back(pair<int, int>(v, d));
    ed[v].push_back(pair<int, int>(u, d));
  }
  priority_queue<pair<long long, long long> > pq;
  vector<long long> d(m);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    tie(x, y, z) = p[i];
    d[z] = min(abs(sx - x), abs(sy - y));
    pq.push(pair<long long, long long>(-d[z], z));
  }
  while (!pq.empty()) {
    long long dd = -pq.top().first;
    int u = pq.top().second;
    pq.pop();
    if (dd > d[u]) continue;
    for (pair<int, int> p : ed[u]) {
      int v = p.first;
      int w = p.second;
      if (w + dd < d[v]) {
        d[v] = w + dd;
        pq.push(pair<long long, long long>(-d[v], v));
      }
    }
  }
  long long ans = abs(sx - fx) + abs(sy - fy);
  for (int i = 0; i < m; i++) {
    int x, y, z;
    tie(x, y, z) = p[i];
    ans = min(ans, d[z] + abs(fx - x) + abs(fy - y));
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
