#include <bits/stdc++.h>
using namespace std;
struct Node {
  int i, d;
  Node(int i, int d) : i(i), d(d) {}
  bool operator<(const Node& other) const { return d > other.d; }
};
int main() {
  int n, m;
  cin >> n >> m;
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  vector<int> a(m), b(m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  vector<int> idxA(m);
  iota(idxA.begin(), idxA.end(), 0);
  sort(idxA.begin(), idxA.end(), [&a](int i, int j) { return a[i] < a[j]; });
  vector<int> idxB(m);
  iota(idxB.begin(), idxB.end(), 0);
  sort(idxB.begin(), idxB.end(), [&b](int i, int j) { return b[i] < b[j]; });
  vector<int> whereA(m), whereB(m);
  for (int i = 0; i < m; i++) {
    whereA[idxA[i]] = i;
    whereB[idxB[i]] = i;
  }
  vector<int> dist(m);
  priority_queue<Node> q;
  for (int i = 0; i < m; i++) {
    dist[i] = min(abs(sx - a[i]), abs(sy - b[i]));
    q.emplace(i, dist[i]);
  }
  while (!q.empty()) {
    Node node = q.top();
    q.pop();
    int i = node.i;
    int d = node.d;
    if (d != dist[i]) {
      continue;
    }
    for (int j = max(0, whereA[i] - 1); j <= min(m - 1, whereA[i] + 1); j++) {
      int k = idxA[j];
      if (k != i) {
        if (dist[k] > dist[i] + abs(a[i] - a[k])) {
          dist[k] = dist[i] + abs(a[i] - a[k]);
          q.emplace(k, dist[k]);
        }
      }
    }
    for (int j = max(0, whereB[i] - 1); j <= min(m - 1, whereB[i] + 1); j++) {
      int k = idxB[j];
      if (k != i) {
        if (dist[k] > dist[i] + abs(b[i] - b[k])) {
          dist[k] = dist[i] + abs(b[i] - b[k]);
          q.emplace(k, dist[k]);
        }
      }
    }
  }
  long long answer = abs(sx - fx) + abs(sy - fy);
  for (int i = 0; i < m; i++) {
    answer = min(answer, dist[i] + abs(a[i] - fx) + (long long)abs(b[i] - fy));
  }
  cout << answer << endl;
}
