#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cout << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cout << '\n'; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cout << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
const long long INF = 2000000000;
vector<vector<pair<long long, long long>>> adj;
void dijkstra(long long s, vector<long long>& d, vector<long long>& p) {
  long long n = adj.size();
  d.assign(n, INF);
  for (long long i = 0; i < n; i++) {
    d[i] = 1e18;
  }
  p.assign(n, -1);
  d[s] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      q;
  q.push({0, s});
  while (!q.empty()) {
    long long v = q.top().second;
    long long d_v = q.top().first;
    q.pop();
    if (d_v != d[v]) continue;
    for (auto edge : adj[v]) {
      long long to = edge.first;
      long long len = edge.second;
      if (d[v] + len < d[to]) {
        d[to] = d[v] + len;
        p[to] = v;
        q.push({d[to], to});
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long TESTS = 1;
  while (TESTS--) {
    long long n, m;
    cin >> n >> m;
    long long sx, sy, fx, fy;
    cin >> sx >> sy >> fx >> fy;
    long long x[m + 1], y[m + 1];
    for (long long i = 1; i <= m; i++) {
      cin >> x[i] >> y[i];
    }
    vector<long long> d(m + 2);
    vector<long long> parr(m + 2);
    adj.resize(m + 2);
    adj[0].push_back({m + 1, abs(sx - fx) + abs(sy - fy)});
    adj[m + 1].push_back({0, abs(sx - fx) + abs(sy - fy)});
    for (long long i = 1; i <= m; i++) {
      adj[0].push_back({i, min(abs(sx - x[i]), abs(sy - y[i]))});
      adj[i].push_back({m + 1, abs(fx - x[i]) + abs(fy - y[i])});
    }
    vector<vector<long long>> v;
    for (long long i = 1; i <= m; i++) {
      v.push_back({x[i], i});
    }
    sort((v).begin(), (v).end());
    for (long long i = 1; i < m; i++) {
      long long p = v[i][1];
      long long q = v[i - 1][1];
      long long d = min(abs(x[p] - x[q]), abs(y[p] - y[q]));
      adj[p].push_back({q, d});
      adj[q].push_back({p, d});
    }
    v.clear();
    for (long long i = 1; i <= m; i++) {
      v.push_back({y[i], i});
    }
    sort((v).begin(), (v).end());
    for (long long i = 1; i < m; i++) {
      long long p = v[i][1];
      long long q = v[i - 1][1];
      long long d = min(abs(x[p] - x[q]), abs(y[p] - y[q]));
      adj[p].push_back({q, d});
      adj[q].push_back({p, d});
    }
    dijkstra(0, d, parr);
    cout << d[m + 1] << '\n';
  }
  return 0;
}
