#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, ax, ay, bx, by, xx, yy;
map<int, vector<int>> adjx, adjy;
vector<int> allx, ally;
pair<int, int> id_point[N];
long long dis[N];
int get_nxt(int x, vector<int>& v) {
  if (x == v.back()) return -1;
  int st = 0, en = v.size() - 1;
  while (st < en) {
    int mid = (st + en) / 2;
    if (v[mid] > x)
      en = mid;
    else
      st = mid + 1;
  }
  return st;
}
int get_prv(int x, vector<int>& v) {
  if (x == v.front()) return -1;
  int st = 0, en = v.size() - 1;
  while (st < en) {
    int mid = (st + en + 1) / 2;
    if (v[mid] >= x)
      en = mid - 1;
    else
      st = mid;
  }
  return st;
}
long long dijkstra() {
  long long ret = abs(ax - bx) + abs(ay - by);
  priority_queue<pair<long long, int>> pq;
  memset(dis, '?', sizeof dis);
  for (int i = 0; i < m; ++i) {
    int x = id_point[i].first;
    int y = id_point[i].second;
    dis[i] = min(abs(x - ax), abs(y - ay));
    pq.push({-dis[i], i});
  }
  while (pq.size()) {
    int idx = pq.top().second;
    int x = id_point[idx].first;
    int y = id_point[idx].second;
    long long d = -pq.top().first;
    pq.pop();
    if (dis[idx] != d) continue;
    ret = min(ret, d + abs(x - bx) + abs(y - by));
    int rx = get_nxt(x, allx);
    int lx = get_prv(x, allx);
    int ry = get_nxt(y, ally);
    int ly = get_prv(y, ally);
    if (rx != -1 && adjx.count(allx[rx])) {
      int i = adjx[allx[rx]][0];
      int xx = id_point[i].first;
      int yy = id_point[i].second;
      long long dd = abs(xx - x);
      if (dis[i] > d + dd) {
        dis[i] = d + dd;
        pq.push({-dis[i], i});
      }
    }
    if (lx != -1 && adjx.count(allx[lx])) {
      int i = adjx[allx[lx]][0];
      int xx = id_point[i].first;
      int yy = id_point[i].second;
      long long dd = abs(xx - x);
      if (dis[i] > d + dd) {
        dis[i] = d + dd;
        pq.push({-dis[i], i});
      }
    }
    if (ry != -1 && adjy.count(ally[ry])) {
      int i = adjy[ally[ry]][0];
      int xx = id_point[i].first;
      int yy = id_point[i].second;
      long long dd = abs(yy - y);
      if (dis[i] > d + dd) {
        dis[i] = d + dd;
        pq.push({-dis[i], i});
      }
    }
    if (ly != -1 && adjy.count(ally[ly])) {
      int i = adjy[ally[ly]][0];
      int xx = id_point[i].first;
      int yy = id_point[i].second;
      long long dd = abs(yy - y);
      if (dis[i] > d + dd) {
        dis[i] = d + dd;
        pq.push({-dis[i], i});
      }
    }
    if (adjx.count(x)) {
      vector<int>& ai = adjx[x];
      for (int i : ai) {
        int xx = id_point[i].first;
        int yy = id_point[i].second;
        if (dis[i] > d) {
          dis[i] = d;
          pq.push({-d, i});
        }
      }
      adjx.erase(x);
    }
    if (adjy.count(y)) {
      vector<int>& ai = adjy[y];
      for (int i : ai) {
        int xx = id_point[i].first;
        int yy = id_point[i].second;
        if (dis[i] > d) {
          dis[i] = d;
          pq.push({-d, i});
        }
      }
      adjy.erase(y);
    }
  }
  return ret;
}
bool Never_give_up() {
  scanf("%d%d", &n, &m);
  scanf("%d%d%d%d", &ax, &ay, &bx, &by);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &xx, &yy);
    id_point[i] = {xx, yy};
    allx.push_back(xx);
    ally.push_back(yy);
    adjx[xx].push_back(i);
    adjy[yy].push_back(i);
  }
  sort(allx.begin(), allx.end());
  sort(ally.begin(), ally.end());
  allx.erase(unique(allx.begin(), allx.end()), allx.end());
  ally.erase(unique(ally.begin(), ally.end()), ally.end());
  printf("%lld\n", dijkstra());
  return 0;
}
int main() {
  int t = 1;
  while (t--) {
    Never_give_up();
  }
  return 0;
}
