#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, int>> G[4000100];
priority_queue<pair<long long, int>, vector<pair<long long, int>>,
               greater<pair<long long, int>>>
    que;
long long d[4000100], INF = 100000000000000000;
void add_edge(int from, int to, long long weight) {
  G[from].push_back({weight, to});
}
void dijkstra(int s) {
  que.push({0, s});
  while (que.size()) {
    pair<long long, int> p = que.top();
    que.pop();
    long long dis = p.first, pos = p.second;
    if (d[pos] != INF) continue;
    d[pos] = dis;
    for (auto e : G[pos]) {
      if (d[e.second] == INF) que.push({dis + e.first, e.second});
    }
  }
}
int a[100010], b[100010];
map<int, int> mpx, mpy;
vector<int> zx, zy;
int main() {
  int i, n, m, sx, sy, gx, gy;
  cin >> n >> m >> sx >> sy >> gx >> gy;
  sx--;
  sy--;
  gx--;
  gy--;
  for (i = 0; i < m; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    mpx[a[i]]++;
    mpy[b[i]]++;
  }
  for (auto x : mpx) zx.push_back(x.first);
  for (auto y : mpy) zy.push_back(y.first);
  for (i = 0; i < zx.size(); i++) mpx[zx[i]] = i;
  for (i = 0; i < zy.size(); i++) mpy[zy[i]] = i + zx.size();
  for (i = 1; i < zx.size(); i++) {
    int aa = zx[i], bb = zx[i - 1];
    add_edge(mpx[aa], mpx[bb], aa - bb);
    add_edge(mpx[bb], mpx[aa], aa - bb);
  }
  for (i = 1; i < zy.size(); i++) {
    int aa = zy[i], bb = zy[i - 1];
    add_edge(mpy[aa], mpy[bb], aa - bb);
    add_edge(mpy[bb], mpy[aa], aa - bb);
  }
  int now = zx.size() + zy.size();
  for (i = 0; i < m; i++) {
    add_edge(now, mpx[a[i]], 0);
    add_edge(mpx[a[i]], now, 0);
    add_edge(now, mpy[b[i]], 0);
    add_edge(mpy[b[i]], now, 0);
    now++;
  }
  int ba = zx.size() + zy.size();
  for (i = 0; i < m; i++) {
    add_edge(ba + i, now, min(abs(a[i] - sx), abs(b[i] - sy)));
    add_edge(now + 1, ba + i, abs(a[i] - gx) + abs(b[i] - gy));
  }
  add_edge(now + 1, now, abs(sx - gx) + abs(sy - gy));
  now += 2;
  for (i = 0; i < now; i++) d[i] = INF;
  dijkstra(now - 1);
  cout << d[now - 2] << endl;
}
