#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, sx, sy, fx, fy;
  cin >> n >> m >> sx >> sy >> fx >> fy;
  vector<pair<pair<int, int>, int> > v(m + 2);
  vector<pair<int, int> > ad[m + 2], aa, bb;
  for (int i = 1; i <= m; i++)
    cin >> v[i].first.first >> v[i].first.second, v[i].second = i;
  for (int i = 1; i <= m; i++) {
    ad[0].push_back(
        {i, min(abs(sx - v[i].first.first), abs(sy - v[i].first.second))});
    ad[i].push_back(
        {m + 1, abs(fx - v[i].first.first) + abs(fy - v[i].first.second)});
  }
  ad[0].push_back({m + 1, abs(sx - fx) + abs(sy - fy)});
  for (int i = 1; i <= m; i++)
    aa.push_back({v[i].first.first, v[i].second}),
        bb.push_back({v[i].first.second, v[i].second});
  sort(aa.begin(), aa.end());
  sort(bb.begin(), bb.end());
  for (int i = 0; i < m; i++) {
    if (i + 1 < m) {
      ad[aa[i].second].push_back(
          {aa[i + 1].second, aa[i + 1].first - aa[i].first});
      ad[aa[i + 1].second].push_back(
          {aa[i].second, aa[i + 1].first - aa[i].first});
    }
  }
  for (int i = 0; i < m; i++) {
    if (i + 1 < m) {
      ad[bb[i].second].push_back(
          {bb[i + 1].second, bb[i + 1].first - bb[i].first});
      ad[bb[i + 1].second].push_back(
          {bb[i].second, bb[i + 1].first - bb[i].first});
    }
  }
  priority_queue<pair<int, int> > pq;
  vector<int> dis(m + 2, 2e9 + 5);
  vector<bool> vis(m + 2, false);
  pq.push({0, 0});
  dis[0] = 0;
  while (!pq.empty()) {
    int a = pq.top().second;
    pq.pop();
    if (vis[a]) continue;
    vis[a] = true;
    for (auto b : ad[a]) {
      if (dis[b.first] > dis[a] + b.second) {
        dis[b.first] = dis[a] + b.second;
        pq.push({-dis[b.first], b.first});
      }
    }
  }
  cout << dis[m + 1] << endl;
  return 0;
}
