#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
int cnt, n, m;
long long d[100005];
int head[100005], vis[100005];
struct cmp {
  bool operator()(const pair<long long, int> p1,
                  const pair<long long, int> p2) {
    return p1.first > p2.first;
  }
};
priority_queue<pair<long long, int>, vector<pair<long long, int> >, cmp> q;
struct node {
  int x, y, wz;
} mp[100005];
struct pp {
  int st, ed, v;
} edge[600500];
void add(int x, int y, int z) {
  edge[++cnt].ed = y;
  edge[cnt].v = z;
  edge[cnt].st = head[x];
  head[x] = cnt;
}
bool cmpx(node x, node y) { return x.x < y.x; }
bool cmpy(node x, node y) { return x.y < y.y; }
void dijkstr() {
  for (int i = 0; i <= m + 2; i++) d[i] = inf;
  d[1] = 0;
  q.push(pair<long long, int>(0, 1));
  while (!q.empty()) {
    int id = q.top().second;
    q.pop();
    if (vis[id]) continue;
    vis[id] = 1;
    for (int i = head[id]; i; i = edge[i].st) {
      int v = edge[i].ed;
      long long w = edge[i].v;
      if (!vis[v] && w + d[id] < d[v]) {
        d[v] = w + d[id];
        q.push(pair<long long, int>(d[v], v));
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  add(1, m + 2, abs(x1 - x2) + abs(y1 - y2));
  for (int i = 2; i <= m + 1; i++)
    scanf("%d%d", &mp[i].x, &mp[i].y),
        mp[i].wz = i, add(1, i, min(abs(mp[i].x - x1), abs(mp[i].y - y1))),
        add(i, m + 2, abs(mp[i].x - x2) + abs(mp[i].y - y2));
  sort(mp + 2, mp + m + 2, cmpx);
  for (int i = 2; i <= m + 1; i++)
    if (i == 2)
      add(mp[i].wz, mp[i + 1].wz, abs(mp[i].x - mp[i + 1].x));
    else if (i == m + 1)
      add(mp[i].wz, mp[i - 1].wz, abs(mp[i].x - mp[i - 1].x));
    else
      add(mp[i].wz, mp[i + 1].wz, abs(mp[i].x - mp[i + 1].x)),
          add(mp[i].wz, mp[i - 1].wz, abs(mp[i].x - mp[i - 1].x));
  sort(mp + 2, mp + m + 2, cmpy);
  for (int i = 2; i <= m + 1; i++)
    if (i == 2)
      add(mp[i].wz, mp[i + 1].wz, abs(mp[i].y - mp[i + 1].y));
    else if (i == m + 1)
      add(mp[i].wz, mp[i - 1].wz, abs(mp[i].y - mp[i - 1].y));
    else
      add(mp[i].wz, mp[i + 1].wz, abs(mp[i].y - mp[i + 1].y)),
          add(mp[i].wz, mp[i - 1].wz, abs(mp[i].y - mp[i - 1].y));
  dijkstr();
  printf("%lld\n", d[m + 2]);
}
