#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e17;
long long int dis1(pair<long long int, long long int> a,
                   pair<long long int, long long int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
long long int dis2(pair<long long int, long long int> a,
                   pair<long long int, long long int> b) {
  return min(abs(a.first - b.first), abs(a.second - b.second));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  pair<long long int, long long int> s, h;
  cin >> s.first >> s.second >> h.first >> h.second;
  vector<pair<long long int, int>> a, b;
  vector<vector<pair<int, long long int>>> v(m + 3);
  for (int i = 2; i <= m + 1; i++) {
    long long int x, y;
    cin >> x >> y;
    a.push_back({x, i});
    b.push_back({y, i});
  }
  for (int i = 0; i < m; i++) {
    v[1].push_back({a[i].second, dis2(s, {a[i].first, b[i].first})});
    v[a[i].second].push_back({1, dis2(s, {a[i].first, b[i].first})});
    v[m + 2].push_back({a[i].second, dis1(h, {a[i].first, b[i].first})});
    v[a[i].second].push_back({m + 2, dis1(h, {a[i].first, b[i].first})});
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < m - 1; i++) {
    auto p1 = a[i], p2 = a[i + 1];
    v[p1.second].push_back({p2.second, abs(p2.first - p1.first)});
    v[p2.second].push_back({p1.second, abs(p1.first - p2.first)});
  }
  for (int i = 0; i < m - 1; i++) {
    auto p1 = b[i], p2 = b[i + 1];
    v[p1.second].push_back({p2.second, abs(p2.first - p1.first)});
    v[p2.second].push_back({p1.second, abs(p1.first - p2.first)});
  }
  v[1].push_back({m + 2, dis1(s, h)});
  v[m + 2].push_back({1, dis1(s, h)});
  vector<long long int> dis(m + 3, inf);
  dis[1] = 0;
  priority_queue<pair<long long int, int>> pq;
  pq.push({0, 1});
  while (!pq.empty()) {
    int nd = pq.top().second;
    pq.pop();
    for (auto p : v[nd])
      if (dis[nd] + p.second < dis[p.first]) {
        dis[p.first] = dis[nd] + p.second;
        pq.push({-dis[p.first], p.first});
      }
  }
  cout << dis[m + 2] << "\n";
}
