#include <bits/stdc++.h>
using namespace std;
int n, m;
int sx, sy, fx, fy;
int px[114514], py[114514];
int pxorder[114514], pyorder[114514];
vector<pair<int, int>> G[114514];
int dist[114514], vis[114514];
int main() {
  cin >> n >> m;
  cin >> sx >> sy >> fx >> fy;
  vector<pair<int, int>> xsort, ysort;
  xsort.push_back(make_pair(sx, 0));
  ysort.push_back(make_pair(sy, 0));
  px[0] = sx;
  py[0] = sy;
  for (int i = 1; i <= m; i++) {
    cin >> px[i] >> py[i];
    xsort.push_back(make_pair(px[i], i));
    ysort.push_back(make_pair(py[i], i));
  }
  sort(xsort.begin(), xsort.end());
  sort(ysort.begin(), ysort.end());
  for (int i = 0; i <= m; i++) {
    pxorder[xsort[i].second] = i;
    pyorder[ysort[i].second] = i;
    dist[i] = 2147483647;
  }
  for (int i = 0; i <= m; i++) {
    if (pxorder[i] != 0) {
      int j = xsort[pxorder[i] - 1].second;
      G[i].push_back(make_pair(j, min(abs(px[i] - px[j]), abs(py[i] - py[j]))));
    }
    if (pxorder[i] != m) {
      int j = xsort[pxorder[i] + 1].second;
      G[i].push_back(make_pair(j, min(abs(px[i] - px[j]), abs(py[i] - py[j]))));
    }
    if (pyorder[i] != 0) {
      int j = ysort[pyorder[i] - 1].second;
      G[i].push_back(make_pair(j, min(abs(px[i] - px[j]), abs(py[i] - py[j]))));
    }
    if (pyorder[i] != m) {
      int j = ysort[pyorder[i] + 1].second;
      G[i].push_back(make_pair(j, min(abs(px[i] - px[j]), abs(py[i] - py[j]))));
    }
  }
  queue<int> Q;
  Q.push(0);
  dist[0] = 0;
  vis[0] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto i : G[u]) {
      int v = i.first, w = i.second;
      if (dist[v] > dist[u] + w) {
        dist[v] = dist[u] + w;
        if (!vis[v]) {
          Q.push(v);
          vis[v] = 1;
        }
      }
    }
    vis[u] = 0;
  }
  int ans = 2147483647;
  for (int i = 0; i <= m; i++) {
    int curr = dist[i] + abs(px[i] - fx) + abs(py[i] - fy);
    ans = min(ans, curr);
  }
  cout << ans;
}
