#include <bits/stdc++.h>
using namespace std;
const int N = 200020;
const int LIM = 100000;
const int MOD = (int)1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
int n, m;
struct node {
  long long x, y;
  int id;
  void read() { cin >> x >> y; }
} p[N];
bool vis[N];
vector<pair<long long, int>> G[N];
long long d[N];
void dijkstra(int s) {
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      pq;
  pq.push({0, s});
  memset(d, 0x3f, sizeof(d));
  d[s] = 0;
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto i : G[u]) {
      int v = i.second;
      if (d[u] + i.first < d[v]) {
        d[v] = d[u] + i.first;
        pq.push({d[v], v});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  p[m + 1].read();
  p[m + 1].id = m + 1;
  p[m + 2].read();
  p[m + 2].id = m + 2;
  for (int i = 1; i <= m; i++) p[i].read(), p[i].id = i;
  m += 2;
  sort(p + 1, p + m, [](node a, node b) {
    if (a.x == b.x) return a.y < b.y;
    return a.x < b.x;
  });
  for (int i = 2; i < m; i++) {
    G[p[i].id].push_back({abs(p[i].x - p[i - 1].x), p[i - 1].id});
    G[p[i - 1].id].push_back({abs(p[i].x - p[i - 1].x), p[i].id});
  }
  sort(p + 1, p + m, [](node a, node b) {
    if (a.y == b.y) return a.x < b.x;
    return a.y < b.y;
  });
  for (int i = 2; i < m; i++) {
    G[p[i].id].push_back({abs(p[i].y - p[i - 1].y), p[i - 1].id});
    G[p[i - 1].id].push_back({abs(p[i].y - p[i - 1].y), p[i].id});
  }
  sort(p + 1, p + 1 + m, [](node a, node b) { return a.id < b.id; });
  for (int i = 1; i <= m - 1; i++) {
    G[p[i].id].push_back(
        {abs(p[i].y - p[m].y) + abs(p[i].x - p[m].x), p[m].id});
    G[p[m].id].push_back(
        {abs(p[i].y - p[m].y) + abs(p[i].x - p[m].x), p[i].id});
  }
  dijkstra(m - 1);
  cout << d[m];
}
