#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
long long fac[1] = {1}, inv[1] = {1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mp(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return ret;
}
long long cmb(long long r, long long c) {
  return (c > r || c < 0) ? 0 : fac[r] * inv[c] % MOD * inv[r - c] % MOD;
}
int n, m;
struct node {
  long long x, y, id;
};
bool cmpx(node a, node b) {
  return pair<long long, long long>(a.x, a.y) <
         pair<long long, long long>(b.x, b.y);
}
bool cmpy(node a, node b) {
  return pair<long long, long long>(a.y, a.x) <
         pair<long long, long long>(b.y, b.x);
}
node vec[100002];
long long dist[100002];
pair<long long, long long> s, e;
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    pq;
vector<pair<long long, long long>> v[100002];
int main() {
  scanf("%d %d", &n, &m);
  scanf("%lld %lld %lld %lld", &s.first, &s.second, &e.first, &e.second);
  vec[0] = {s.first, s.second, 0};
  vec[m + 1] = {e.first, e.second, m + 1};
  for (int i = 1; i <= m; i++) {
    scanf("%lld %lld", &vec[i].x, &vec[i].y);
    vec[i].id = i;
    v[0].push_back({abs(s.first - vec[i].x), i});
    v[0].push_back({abs(s.second - vec[i].y), i});
    v[i].push_back({abs(e.first - vec[i].x) + abs(e.second - vec[i].y), m + 1});
  }
  v[0].push_back({abs(s.first - e.first) + abs(s.second - e.second), m + 1});
  sort(vec + 1, vec + m + 1, cmpx);
  for (int i = 1; i <= m; i++) {
    int me = vec[i].id;
    if (i != 1) v[me].push_back({vec[i].x - vec[i - 1].x, vec[i - 1].id});
    if (i != m) v[me].push_back({vec[i + 1].x - vec[i].x, vec[i + 1].id});
  }
  sort(vec + 1, vec + m + 1, cmpy);
  for (int i = 1; i <= m; i++) {
    int me = vec[i].id;
    if (i != 1) v[me].push_back({vec[i].y - vec[i - 1].y, vec[i - 1].id});
    if (i != m) v[me].push_back({vec[i + 1].y - vec[i].y, vec[i + 1].id});
  }
  memset(dist, 0x3f, sizeof(dist));
  pq.push({0, 0});
  dist[0] = 0;
  while (!pq.empty()) {
    pair<long long, long long> tv = pq.top();
    pq.pop();
    if (tv.first != dist[tv.second]) continue;
    for (pair<long long, long long> i : v[tv.second]) {
      if (dist[i.second] > i.first + tv.first) {
        dist[i.second] = i.first + tv.first;
        pq.push({dist[i.second], i.second});
      }
    }
  }
  printf("%lld", dist[m + 1]);
}
