#include <bits/stdc++.h>
using namespace std;
struct Point {
  long long x, y;
  long long id;
  Point(long long a, long long b, long long i) {
    x = a;
    y = b;
    id = i;
  }
  long long dist(Point &other) { return abs(x - other.x) + abs(y - other.y); }
  long long xDist(Point &other) { return abs(x - other.x); }
  long long yDist(Point &other) { return abs(y - other.y); }
  long long bdist(Point &other) { return min(xDist(other), yDist(other)); }
};
bool sortByX(Point &a, Point &b) { return a.x < b.x; }
bool sortByY(Point &a, Point &b) { return a.y < b.y; }
struct Edge {
  long long node, weight;
  Edge(long long n, long long w) : node(n), weight(w) {}
};
int solve() {
  int N, M;
  cin >> N >> M;
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  Point S = Point(sx, sy, 0);
  Point F = Point(fx, fy, 1);
  vector<Point> p;
  vector<Edge> E[M + 2];
  for (long long i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    p.push_back(Point(a, b, i + 2));
  }
  sort(p.begin(), p.end(), sortByX);
  for (long long i = 0; i < M - 1; i++) {
    Point f = p[i];
    Point s = p[i + 1];
    E[f.id].push_back(Edge(s.id, f.xDist(s)));
    E[s.id].push_back(Edge(f.id, s.xDist(f)));
  }
  sort(p.begin(), p.end(), sortByY);
  for (long long i = 0; i < M - 1; i++) {
    Point f = p[i];
    Point s = p[i + 1];
    E[f.id].push_back(Edge(s.id, f.yDist(s)));
    E[s.id].push_back(Edge(f.id, s.yDist(f)));
  }
  for (long long i = 0; i < M; i++) {
    Point u = p[i];
    E[0].push_back(Edge(u.id, S.bdist(u)));
    E[u.id].push_back(Edge(0, u.dist(S)));
    E[u.id].push_back(Edge(1, u.dist(F)));
  }
  E[0].push_back(Edge(1, S.dist(F)));
  E[1].push_back(Edge(0, F.dist(S)));
  long long d[M + 2];
  for (long long i = 0; i < M + 2; i++) d[i] = 3000000005;
  d[0] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      q;
  q.push(make_pair(0, 0));
  set<int> visited;
  while (!q.empty()) {
    pair<long long, long long> pa = q.top();
    q.pop();
    int node = pa.second;
    int dist = pa.first;
    if (dist != d[node]) continue;
    if (visited.count(node)) continue;
    visited.insert(node);
    for (auto psosed : E[node]) {
      int sosed = psosed.node;
      int add = psosed.weight;
      if (d[sosed] > dist + add) {
        d[sosed] = dist + add;
        q.push(make_pair(d[sosed], sosed));
      }
    }
  }
  return d[1];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t = 1;
  while (t--) cout << solve() << endl;
}
