#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long inf = 0x3f3f3f3f3f3f3f;
int x[N], y[N], n, m, a, b;
long long d[N];
set<pair<int, int> > p1, p2;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
void solve(int u, int v) {
  int dis = d[u] + min(abs(x[u] - x[v]), abs(y[u] - y[v]));
  if (dis < d[v]) d[v] = dis, q.push({dis, v});
}
void dij() {
  memset(d, inf, sizeof(d));
  d[0] = 0, q.push({0, 0});
  while (!q.empty()) {
    int ix = q.top().first, id = q.top().second;
    q.pop();
    if (d[id] != ix) continue;
    p1.erase({x[id], id}), p2.erase({y[id], id});
    auto it = p1.lower_bound({x[id], 0});
    if (it != p1.end()) solve(id, (*it).second);
    if (it != p1.begin()) it--, solve(id, (*it).second);
    it = p2.lower_bound({y[id], 0});
    if (it != p2.end()) solve(id, (*it).second);
    if (it != p2.begin()) it--, solve(id, (*it).second);
  }
  long long ans = inf;
  for (int i = 0; i <= m; i++)
    ans = min(ans, d[i] + abs(x[i] - a) + abs(y[i] - b));
  printf("%lld\n", ans);
}
int main() {
  scanf("%d%d%d%d%d%d", &n, &m, &x[0], &y[0], &a, &b);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    p1.insert({x[i], i});
    p2.insert({y[i], i});
  }
  dij();
  return 0;
}
