#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
const int MAXN = 1e5 + 5;
vector<long long int> dist(MAXN, (long long int)(1e18));
vector<vector<pair<long long int, long long int>>> adj(MAXN);
vector<pair<pair<int, int>, int>> p;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  pair<int, int> s, f;
  cin >> s.first >> s.second >> f.first >> f.second;
  p.push_back({s, 0});
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    p.push_back({{x, y}, i});
  }
  for (int i = 0; i < 2; i++) {
    sort(p.begin(), p.end());
    for (int j = 1; j < m + 1; j++) {
      int x = p[j].first.first;
      int y = p[j].first.second;
      int id = p[j].second;
      int x1 = p[j - 1].first.first;
      int y1 = p[j - 1].first.second;
      int id1 = p[j - 1].second;
      int cost = min(abs(x - x1), abs(y - y1));
      adj[id1].push_back({id, cost});
      adj[id].push_back({id1, cost});
    }
    for (auto &x : p) {
      swap(x.first.first, x.first.second);
    }
  }
  for (auto x : p) {
    adj[x.second].push_back(
        {m + 1, abs(x.first.first - f.first) + abs(x.first.second - f.second)});
  }
  dist[0] = 0;
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int>>,
                 greater<pair<long long int, long long int>>>
      pq;
  pq.push({0, 0});
  while (!pq.empty()) {
    int v = pq.top().second;
    pq.pop();
    for (auto x : adj[v]) {
      if (dist[x.first] > dist[v] + x.second) {
        dist[x.first] = dist[v] + x.second;
        pq.push({dist[x.first], x.first});
      }
    }
  }
  cout << dist[m + 1] << '\n';
}
