#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e14;
long long dijkstra(int s, int f,
                   const vector<vector<pair<int, long long>>>& adj) {
  int n = (int)adj.size();
  vector<long long> dist(n, inf);
  using pii = pair<long long, int>;
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  pq.push({0, s});
  dist[s] = 0;
  while (!pq.empty()) {
    long long d = pq.top().first;
    int u = pq.top().second;
    pq.pop();
    if (d > dist[u]) {
      continue;
    }
    for (auto e : adj[u]) {
      int v = e.first;
      long long w = e.second;
      if (dist[v] > dist[u] + w) {
        dist[v] = dist[u] + w;
        pq.push({dist[v], v});
      }
    }
  }
  return dist[f];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  pair<int, int> s, f;
  cin >> s.first >> s.second >> f.first >> f.second;
  vector<tuple<int, int>> xs, ys;
  vector<vector<pair<int, long long>>> adj(m + 2);
  adj[0].emplace_back(m + 1, abs(s.first - f.first) + abs(s.second - f.second));
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    adj[0].emplace_back(i, min(abs(x - s.first), abs(y - s.second)));
    adj[i].emplace_back(m + 1, abs(x - f.first) + abs(y - f.second));
    xs.emplace_back(x, i);
    ys.emplace_back(y, i);
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  for (int i = 1; i < m; i++) {
    int a[2], b[2];
    tie(a[0], a[1]) = xs[i];
    tie(b[0], b[1]) = xs[i - 1];
    adj[a[1]].emplace_back(b[1], abs(a[0] - b[0]));
    adj[b[1]].emplace_back(a[1], abs(a[0] - b[0]));
    tie(a[0], a[1]) = ys[i];
    tie(b[0], b[1]) = ys[i - 1];
    adj[a[1]].emplace_back(b[1], abs(a[0] - b[0]));
    adj[b[1]].emplace_back(a[1], abs(a[0] - b[0]));
  }
  cout << dijkstra(0, m + 1, adj) << '\n';
  return 0;
}
