#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const vector<int> mods = {998244353, 1000000007, 1000000009};
const long long inf = 3e18;
const double pi = acos(-1.0);
const double eps = 0.0000001;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <class... K>
using umap = unordered_map<K...>;
template <class... K>
using uset = unordered_set<K...>;
const int N = 100100;
long long n, m;
long long sx, sy, fx, fy, mdis[N];
using pt = array<long long, 3>;
vector<pt> pts;
umap<long long, vector<pair<long long, long long> > > g;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(13);
  cin >> n >> m;
  cin >> sx >> sy >> fx >> fy;
  pts.resize(m + 1);
  for (long long i = (0); i < (m); ++i) {
    cin >> pts[i][0] >> pts[i][1];
    pts[i][2] = i;
  }
  pts[m] = {sx, sy, m};
  for (long long i = (0); i < (m + 1); ++i) {
    long long dis = abs(pts[i][0] - fx) + abs(pts[i][1] - fy);
    g[pts[i][2]].push_back({m + 1, dis});
  }
  for (long long dim = (0); dim < (2); ++dim) {
    sort(begin(pts), end(pts), [&](pt& a, pt& b) { return a[dim] > b[dim]; });
    for (long long i = (0); i < (m); ++i) {
      long long dis = abs(pts[i][dim] - pts[i + 1][dim]);
      g[pts[i][2]].push_back({pts[i + 1][2], dis});
      g[pts[i + 1][2]].push_back({pts[i][2], dis});
    }
  }
  fill(&mdis[0], &mdis[0] + sizeof(mdis) / sizeof(mdis[0]) - 1, inf);
  priority_queue<pair<long long, long long> > pq;
  pq.push({0, m});
  while (((int)(pq).size())) {
    auto [dis, x] = pq.top();
    dis = -dis;
    pq.pop();
    if (dis >= mdis[x]) continue;
    mdis[x] = dis;
    if (x == m + 1) break;
    for (auto& nx : g[x]) {
      pq.push({-(nx.second + dis), nx.first});
    }
  }
  cout << mdis[m + 1] << "\n";
  return 0;
}
