#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, mod = 1e9 + 7, inv2 = 5e8 + 4;
const long long inf = 1e18;
int n, m, fx, fy, vis[maxn];
struct Point {
  int x, y;
} p[maxn];
vector<pair<int, int>> vec, G[maxn];
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    que;
long long d[maxn];
void diji(int s) {
  memset(d, 0x3f, sizeof(d));
  d[0] = 0, que.push({0, 0});
  while (!que.empty()) {
    int u = que.top().second;
    que.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (auto p : G[u]) {
      if (d[u] + p.second >= d[p.first]) continue;
      d[p.first] = d[u] + p.second;
      que.push({d[p.first], p.first});
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d%d%d", &p[0].x, &p[0].y, &fx, &fy);
  for (int i = 1; i <= m; i++) scanf("%d%d", &p[i].x, &p[i].y);
  for (int i = 0; i <= m; i++) vec.push_back({p[i].x, i});
  sort(vec.begin(), vec.end());
  for (int i = 1; i <= m; i++) {
    G[vec[i].second].push_back(
        {vec[i - 1].second, vec[i].first - vec[i - 1].first});
    G[vec[i - 1].second].push_back(
        {vec[i].second, vec[i].first - vec[i - 1].first});
  }
  vec.clear();
  for (int i = 0; i <= m; i++) vec.push_back({p[i].y, i});
  sort(vec.begin(), vec.end());
  for (int i = 1; i <= m; i++) {
    G[vec[i].second].push_back(
        {vec[i - 1].second, vec[i].first - vec[i - 1].first});
    G[vec[i - 1].second].push_back(
        {vec[i].second, vec[i].first - vec[i - 1].first});
  }
  diji(0);
  long long ans = inf;
  for (int i = 0; i <= m; i++)
    ans = min(ans, d[i] + abs(p[i].x - fx) + abs(p[i].y - fy));
  printf("%lld\n", ans);
  return 0;
}
