#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
vector<pair<int, int>> g[MAXN];
long long dist[MAXN];
void dijkstra(int x) {
  memset(dist, -1, sizeof(dist));
  priority_queue<pair<long long, int>> q;
  dist[x] = 0;
  q.push({0, x});
  while (!q.empty()) {
    x = q.top().second;
    long long c = -q.top().first;
    q.pop();
    if (dist[x] != c) continue;
    for (int i = 0, ThxDem = g[x].size(); i < ThxDem; ++i) {
      int y = g[x][i].first;
      long long c = g[x][i].second;
      if (dist[y] < 0 || dist[x] + c < dist[y])
        dist[y] = dist[x] + c, q.push({-dist[y], y});
    }
  }
}
void add(int x, int y, int w) {
  g[x].push_back({y, w});
  g[y].push_back({x, w});
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int asd, n;
  cin >> asd >> n;
  int sx, sy, ex, ey;
  cin >> sx >> sy >> ex >> ey;
  vector<pair<pair<int, int>, int>> v(n);
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    cin >> v[i].first.first >> v[i].first.second, v[i].second = i;
  for (int it = 0, ThxDem = 2; it < ThxDem; ++it) {
    sort(v.begin(), v.end());
    int ps = 0;
    for (int i = 0, ThxDem = n; i < ThxDem; ++i) {
      if (i + 1 < n && v[i].first.first == v[i + 1].first.first)
        add(v[i].second, v[i + 1].second, 0);
      while (ps < n && v[i].first.first == v[ps].first.first) ps++;
      if (ps < n)
        add(v[i].second, v[ps].second, v[ps].first.first - v[i].first.first);
    }
    for (int i = 0, ThxDem = n; i < ThxDem; ++i)
      swap(v[i].first.first, v[i].first.second);
  }
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    add(n, v[i].second,
        min(abs(sx - v[i].first.first), abs(sy - v[i].first.second)));
  for (int i = 0, ThxDem = n; i < ThxDem; ++i)
    add(n + 1, v[i].second,
        abs(ex - v[i].first.first) + abs(ey - v[i].first.second));
  add(n, n + 1, abs(sx - ex) + abs(sy - ey));
  dijkstra(n);
  cout << dist[n + 1] << "\n";
}
