#include <bits/stdc++.h>
using namespace std;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vc<vc<T>>;
template <class T>
void mkuni(vector<T> &v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
long long rand_int(long long l, long long r) {
  static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<long long>(l, r)(gen);
}
template <class T>
void print(T x, int suc = 1) {
  cout << x;
  if (suc == 1)
    cout << '\n';
  else
    cout << ' ';
}
template <class T>
void print(const vector<T> &v, int suc = 1) {
  for (int i = 0; i < v.size(); i++)
    print(v[i], i == (int)(v.size()) - 1 ? suc : 2);
}
const int INF = 0x3f3f3f;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 7;
struct node {
  int x, y, id;
} a[maxn + 10];
int n, m, sx, sy, fx, fy;
vc<pair<long long, long long>> g[maxn << 2];
long long d[maxn];
bool cmp1(node a, node b) { return a.x < b.x; }
bool cmp2(node a, node b) { return a.y < b.y; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> sx >> sy >> fx >> fy;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    a[i] = {x, y, i};
    g[m].emplace_back(i, min(abs(sx - x), abs(sy - y)));
    g[i].emplace_back(m + 1, abs(fx - x) + abs(fy - y));
  }
  sort(a, a + m, cmp1);
  for (int i = 0; i < m - 1; ++i) {
    g[a[i].id].emplace_back(a[i + 1].id, a[i + 1].x - a[i].x);
    g[a[i + 1].id].emplace_back(a[i].id, a[i + 1].x - a[i].x);
  }
  sort(a, a + m, cmp2);
  for (int i = 0; i < m - 1; ++i) {
    g[a[i].id].emplace_back(a[i + 1].id, a[i + 1].y - a[i].y);
    g[a[i + 1].id].emplace_back(a[i].id, a[i + 1].y - a[i].y);
  }
  for (int i = 0; i <= m + 1; ++i) d[i] = 1e18;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  d[m] = 0, pq.emplace(0, m);
  while (pq.size()) {
    pair<int, int> cur = pq.top();
    pq.pop();
    long long dis = cur.first, dian = cur.second;
    for (auto &u : g[dian]) {
      long long D = dis + u.second;
      if (d[u.first] > D) {
        ;
        d[u.first] = D;
        pq.emplace(D, u.first);
      }
    }
  }
  cout << min((long long)abs(sx - fx) + abs(sy - fy), d[m + 1]) << '\n';
}
