#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
struct port {
  int id;
  int x, y;
};
void solve() {
  int n, m, sx, sy, dx, dy;
  cin >> n >> m >> sx >> sy >> dx >> dy;
  vector<port> p;
  for (int i = 0, x, y; i < m; ++i) {
    cin >> x >> y;
    p.push_back({i + 1, x, y});
  }
  vector<array<int, 2>> adj[m + 3];
  for (auto &i : p) {
    int wt = min(abs(i.x - sx), abs(i.y - sy));
    adj[m + 1].push_back({i.id, wt});
    adj[i.id].push_back({m + 1, wt});
  }
  for (auto &i : p) {
    int wt = abs(i.x - dx) + abs(i.y - dy);
    adj[m + 2].push_back({i.id, wt});
    adj[i.id].push_back({m + 2, wt});
  }
  sort(begin(p), end(p), [&](port a, port b) { return a.x < b.x; });
  for (int i = 1; i < m; ++i) {
    int j = i - 1, wt = abs(p[i].x - p[j].x);
    adj[p[i].id].push_back({p[j].id, wt});
    adj[p[j].id].push_back({p[i].id, wt});
  }
  sort(begin(p), end(p), [&](port a, port b) { return a.y < b.y; });
  for (int i = 1; i < m; ++i) {
    int j = i - 1, wt = abs(p[i].y - p[j].y);
    adj[p[i].id].push_back({p[j].id, wt});
    adj[p[j].id].push_back({p[i].id, wt});
  }
  int wt = abs(dx - sx) + abs(dy - sy);
  adj[m + 1].push_back({m + 2, wt});
  adj[m + 2].push_back({m + 1, wt});
  auto dijkstra = [&](int src, int des) {
    vector<long long> dist(m + 3, inf);
    priority_queue<array<long long, 2>, vector<array<long long, 2>>,
                   greater<array<long long, 2>>>
        pq;
    dist[src] = 0;
    pq.push({0, src});
    while (!pq.empty()) {
      long long curdist = pq.top()[0];
      long long curnode = pq.top()[1];
      pq.pop();
      if (curdist > dist[curnode]) continue;
      for (auto &[v, w] : adj[curnode]) {
        if (dist[curnode] + w < dist[v]) {
          dist[v] = dist[curnode] + w;
          pq.push({dist[v], v});
        }
      }
    }
    return dist[des];
  };
  cout << dijkstra(m + 1, m + 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int tc;
  tc = 1;
  while (tc--) solve();
}
