#include <bits/stdc++.h>
using namespace std;
long long inf = pow(10, 12);
long long calc(pair<long long, long long> a, pair<long long, long long> b) {
  return min(abs(a.first - b.first), abs(a.second - b.second));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  sx--;
  sy--;
  fx--;
  fy--;
  vector<tuple<long long, long long, long long>> row(m + 1);
  vector<tuple<long long, long long, long long>> col(m + 1);
  row[0] = make_tuple(sy, sx, 0);
  col[0] = make_tuple(sx, sy, 0);
  vector<pair<long long, long long>> inst(m + 1);
  inst[0] = make_pair(sx, sy);
  long long x, y;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    x--;
    y--;
    inst[i] = make_pair(x, y);
    row[i] = make_tuple(y, x, i);
    col[i] = make_tuple(x, y, i);
  }
  sort(row.begin(), row.end());
  sort(col.begin(), col.end());
  vector<vector<long long>> adj(m + 1);
  long long a, b, c;
  long long d, e, f;
  for (int i = 0; i <= m; i++) {
    tie(a, b, c) = col[i];
    if (i > 0) {
      tie(d, e, f) = col[i - 1];
      adj[c].push_back(f);
    }
    if (i < m) {
      tie(d, e, f) = col[i + 1];
      adj[c].push_back(f);
    }
  }
  for (int i = 0; i <= m; i++) {
    tie(a, b, c) = row[i];
    if (i > 0) {
      tie(d, e, f) = row[i - 1];
      adj[c].push_back(f);
    }
    if (i < m) {
      tie(d, e, f) = row[i + 1];
      adj[c].push_back(f);
    }
  }
  vector<long long> dist(m + 2, inf);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  pq.push(make_pair(0, 0));
  dist[0] = 0;
  long long addCost;
  long long cost, node;
  while (!pq.empty()) {
    cost = pq.top().first;
    node = pq.top().second;
    pq.pop();
    if (node == m + 1) {
      cout << cost << '\n';
      break;
    }
    if (cost > dist[node] || cost >= dist[m + 1]) continue;
    long long next;
    for (int i = 0; i < adj[node].size(); i++) {
      next = adj[node][i];
      addCost = calc(inst[node], inst[next]);
      if (dist[next] <= cost + addCost) continue;
      dist[next] = cost + addCost;
      pq.push(make_pair(dist[next], next));
    }
    addCost = abs(inst[node].first - fx) + abs(inst[node].second - fy);
    if (dist[m + 1] > addCost + cost) {
      dist[m + 1] = addCost + cost;
      pq.push(make_pair(dist[m + 1], m + 1));
    }
  }
  return 0;
}
