#include <bits/stdc++.h>
using namespace std;
const long long nax = 1e5 + 1;
vector<long long> g[nax];
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> s, t;
  cin >> s.first >> s.second >> t.first >> t.second;
  pair<long long, long long> a[m];
  for (long long i = 0; i < m; i++) cin >> a[i].first >> a[i].second;
  pair<long long, long long> b[m];
  for (long long i = 0; i < m; i++) b[i].first = a[i].first, b[i].second = i;
  sort(b, b + m);
  for (long long i = 0; i < m; i++) {
    if (i - 1 >= 0) g[b[i].second].push_back(b[i - 1].second);
    if (i + 1 < m) g[b[i].second].push_back(b[i + 1].second);
  }
  for (long long i = 0; i < m; i++) b[i].first = a[i].second, b[i].second = i;
  sort(b, b + m);
  for (long long i = 0; i < m; i++) {
    if (i - 1 >= 0) g[b[i].second].push_back(b[i - 1].second);
    if (i + 1 < m) g[b[i].second].push_back(b[i + 1].second);
  }
  long long res = abs(s.first - t.first) + abs(s.second - t.second);
  long long cost[m];
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  for (long long i = 0; i < m; i++) {
    cost[i] = min(abs(s.first - a[i].first), abs(s.second - a[i].second));
    pq.push({cost[i], i});
  }
  bool vis[m];
  memset(vis, 0, sizeof(vis));
  while (!pq.empty()) {
    auto p = pq.top();
    pq.pop();
    vis[p.second] = 1;
    for (auto &u : g[p.second]) {
      if (!vis[u]) {
        long long cc = cost[p.second];
        cc += min(abs(a[p.second].first - a[u].first),
                  abs(a[p.second].second - a[u].second));
        if (cc < cost[u]) {
          cost[u] = cc;
          pq.push({cost[u], u});
        }
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    res = min(
        res, abs(t.first - a[i].first) + abs(t.second - a[i].second) + cost[i]);
  }
  cout << res;
}
