#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != (int)v.size() ? " " : "");
  }
  return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}
struct dijkstra {
  int n;
  const ll inf = 4e18;
  vector<ll> dists;
  vector<int> par;
  vector<bool> vis;
  vector<vector<pair<ll, int>>> edges;
  void init(int s) {
    n = s;
    dists = vector<ll>(n);
    vis = vector<bool>(n);
    par = vector<int>(n);
    edges = vector<vector<pair<ll, int>>>(n);
  }
  void edge(int a, int b, ll wt) { edges[a].emplace_back(wt, b); }
  using ptype = pair<ll, int>;
  void run(int src) {
    fill(dists.begin(), dists.end(), inf);
    fill(vis.begin(), vis.end(), false);
    fill(par.begin(), par.end(), -1);
    priority_queue<ptype, vector<ptype>, greater<ptype>> pq;
    dists[src] = 0;
    pq.emplace(0, src);
    while (!pq.empty()) {
      ptype foc = pq.top();
      pq.pop();
      if (vis[foc.second]) continue;
      vis[foc.second] = 1;
      dists[foc.second] = min(dists[foc.second], foc.first);
      for (ptype x : edges[foc.second]) {
        ll d = dists[foc.second] + x.first;
        if (d >= dists[x.second]) continue;
        dists[x.second] = d;
        par[x.second] = foc.second;
        pq.emplace(d, x.second);
      }
    }
  }
};
dijkstra d;
pair<pair<ll, ll>, ll> p[100100];
int main() {
  ll n, m;
  cin >> n >> m;
  ll sx, sy, fx, fy;
  cin >> sx >> sy >> fx >> fy;
  d.init(m + 2);
  d.edge(m, m + 1, abs(sx - fx) + abs(sy - fy));
  for (int i = 0; i < m; ++i) {
    cin >> p[i].first;
    p[i].second = i;
  }
  for (int i = 0; i < m; ++i) {
    d.edge(m, i, abs(sx - p[i].first.first));
    d.edge(m, i, abs(sy - p[i].first.second));
    d.edge(i, m + 1, abs(fx - p[i].first.first) + abs(fy - p[i].first.second));
  }
  sort(p, p + m);
  for (int i = 0; i + 1 < m; ++i) {
    d.edge(p[i].second, p[i + 1].second,
           abs(p[i].first.first - p[i + 1].first.first));
    d.edge(p[i + 1].second, p[i].second,
           abs(p[i].first.first - p[i + 1].first.first));
  }
  for (int i = 0; i < m; ++i) {
    swap(p[i].first.first, p[i].first.second);
  }
  sort(p, p + m);
  for (int i = 0; i < m; ++i) {
    swap(p[i].first.first, p[i].first.second);
  }
  for (int i = 0; i + 1 < m; ++i) {
    d.edge(p[i].second, p[i + 1].second,
           abs(p[i].first.second - p[i + 1].first.second));
    d.edge(p[i + 1].second, p[i].second,
           abs(p[i].first.second - p[i + 1].first.second));
  }
  d.run(m);
  cout << d.dists[m + 1] << endl;
}
