#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long maxn = 4e5 + 7;
vector<pair<long long, long long> > G[maxn];
vector<long long> dis(maxn, -1);
vector<long long> xaxis, yaxis;
pair<long long, long long> loct[maxn];
struct Node {
  long long u, w;
  bool operator<(const Node &tmp) const { return tmp.w < w; }
};
void add_edge(long long u, long long v, long long w) {
  G[u].emplace_back(v, w);
  G[v].emplace_back(u, w);
}
long long dijk(long long m) {
  priority_queue<Node> pq;
  dis[0] = 0;
  pq.push({0, 0});
  while (pq.size()) {
    auto now = pq.top();
    pq.pop();
    dis[now.u] = now.w;
    if (now.u == m) return now.w;
    for (auto k : G[now.u]) {
      if (dis[k.first] == -1) {
        pq.push({k.first, now.w + k.second});
      }
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  pair<long long, long long> st, ed;
  cin >> st.first >> st.second >> ed.first >> ed.second;
  add_edge(0, 3 * m + 1, abs(st.first - ed.first) + abs(st.second - ed.second));
  for (long long i = 1; i <= m; i++) {
    cin >> loct[i].first >> loct[i].second;
    xaxis.push_back(loct[i].first);
    yaxis.push_back(loct[i].second);
  }
  sort(xaxis.begin(), xaxis.end());
  sort(yaxis.begin(), yaxis.end());
  for (long long i = 1; i <= m; i++) {
    add_edge(
        0, i,
        min(abs(loct[i].first - st.first), abs(loct[i].second - st.second)));
    add_edge(3 * m + 1, i,
             abs(loct[i].first - ed.first) + abs(loct[i].second - ed.second));
  }
  for (long long i = 0; i < m - 1; i++) {
    add_edge(i + 1 + m, i + 2 + m, xaxis[i + 1] - xaxis[i]);
    add_edge(i + 1 + m * 2, i + 2 + m * 2, yaxis[i + 1] - yaxis[i]);
  }
  for (long long i = 1; i <= m; i++) {
    long long idx = lower_bound(xaxis.begin(), xaxis.end(), loct[i].first) -
                    xaxis.begin() + 1;
    long long idy = lower_bound(yaxis.begin(), yaxis.end(), loct[i].second) -
                    yaxis.begin() + 1;
    add_edge(i, idx + m, 0);
    add_edge(i, idy + m * 2, 0);
  }
  cout << dijk(3 * m + 1);
}
