#include <bits/stdc++.h>
using namespace std;
void foo() {
  int n, m;
  cin >> n >> m;
  int sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  vector<pair<long long, long long> > a;
  for (int i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    a.push_back({x, y});
  }
  auto md = [&](pair<long long, long long> &p) {
    return abs(p.first - fx) + abs(p.second - fy);
  };
  auto compX = [&](const int &ind1, const int &ind2) {
    pair<long long, long long> p1 = a[ind1];
    pair<long long, long long> p2 = a[ind2];
    return p1.first < p2.first || (p1.first == p2.first && ind1 < ind2);
  };
  auto compY = [&](const int &ind1, const int &ind2) {
    pair<long long, long long> p1 = a[ind1];
    pair<long long, long long> p2 = a[ind2];
    return p1.second < p2.second || (p1.second == p2.second && ind1 < ind2);
  };
  multiset<int, decltype(compX)> xx(compX);
  multiset<int, decltype(compY)> yy(compY);
  for (int i = 0; i < m; i++) {
    xx.insert(i);
    yy.insert(i);
  }
  priority_queue<pair<long long, long long> > pq;
  vector<long long> dist(m);
  for (int i = 0; i < m; i++) {
    dist[i] = md(a[i]);
    pq.push({-dist[i], i});
  }
  vector<bool> vis(m, false);
  while (!pq.empty()) {
    pair<long long, long long> p = pq.top();
    pq.pop();
    int ind = p.second;
    pair<long long, long long> me = a[ind];
    if (vis[ind]) continue;
    assert(dist[ind] == -p.first);
    vis[ind] = true;
    const auto itx = xx.find(ind);
    const auto ity = yy.find(ind);
    auto top = ity;
    top++;
    if (top != yy.end()) {
      pair<long long, long long> pr = a[*top];
      long long cd = dist[ind] + abs(me.second - pr.second);
      if (cd < dist[*top]) {
        dist[*top] = cd;
        pq.push({-cd, *top});
      }
    }
    auto right = itx;
    right++;
    if (right != xx.end()) {
      pair<long long, long long> pr = a[*right];
      long long cd = dist[ind] + abs(me.first - pr.first);
      if (cd < dist[*right]) {
        dist[*right] = cd;
        pq.push({-cd, *right});
      }
    }
    if (yy.begin() != ity) {
      auto bottom = ity;
      bottom--;
      pair<long long, long long> pr = a[*bottom];
      long long cd = dist[ind] + abs(me.second - pr.second);
      if (cd < dist[*bottom]) {
        dist[*bottom] = cd;
        pq.push({-cd, *bottom});
      }
    }
    if (xx.begin() != itx) {
      auto left = itx;
      left--;
      pair<long long, long long> pr = a[*left];
      long long cd = dist[ind] + abs(me.first - pr.first);
      if (cd < dist[*left]) {
        dist[*left] = cd;
        pq.push({-cd, *left});
      }
    }
  }
  long long ans = abs(sx - fx) + abs(sy - fy);
  for (int i = 0; i < m; i++) {
    pair<long long, long long> p = a[i];
    long long d = min(abs(sx - p.first), abs(sy - p.second)) + dist[i];
    ans = min(ans, d);
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  foo();
}
