#include <bits/stdc++.h>
template <typename T1, typename T2>
inline bool chkmin(T1& x, const T2& y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chkmax(T1& x, const T2& y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
using namespace std;
const long long maxn = 2e5 + 20;
ostream& operator<<(ostream& out, vector<long long>& v) {
  for (auto& x : v) out << x << ' ';
  return out;
}
ostream& operator<<(ostream& out, pair<long long, long long>& v) {
  out << v.first << ", " << v.second;
  return out;
}
istream& operator>>(istream& in, pair<long long, long long>& a) {
  in >> a.first >> a.second;
  return in;
}
const long long inf = (long long)2e9;
const long double pi = asin(1) * 2;
const long double eps = 1e-8;
const long long mod = (long long)1e9 + 7;
const long long ns = 97;
const long long C = 1e5;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
pair<long long, long long> s, f;
vector<pair<long long, long long>> goo;
map<long long, vector<long long>> gx, gy;
vector<pair<long long, long long>> g[maxn];
long long S = 2e5, F = 2e5 + 1;
map<pair<long long, long long>, long long> key;
long long d[maxn];
long long Dijkstra() {
  set<pair<long long, long long>> a;
  for (auto& x : d) x = inf;
  d[S] = 0;
  a.insert({0, S});
  while (!a.empty()) {
    long long v = a.begin()->second;
    a.erase(a.begin());
    for (auto& u : g[v]) {
      long long to = u.first, c = u.second;
      if (d[to] > d[v] + c) {
        a.erase({d[to], to});
        d[to] = d[v] + c;
        a.insert({d[to], to});
      }
    }
  }
  return d[F];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, m;
  cin >> n >> m;
  cin >> s;
  cin >> f;
  goo = vector<pair<long long, long long>>(m);
  for (auto& x : goo) cin >> x;
  vector<long long> x, y;
  for (auto& t : goo) {
    gx[t.first].push_back(t.second);
    gy[t.second].push_back(t.first);
    x.push_back(t.first);
    y.push_back(t.second);
  }
  key[s] = S;
  key[f] = F;
  for (long long i = 0; i < m; ++i) key[goo[i]] = i;
  x.push_back(s.first);
  x.push_back(f.first);
  y.push_back(s.second);
  y.push_back(f.second);
  sort(x.begin(), x.end());
  x.resize(unique(x.begin(), x.end()) - x.begin());
  sort(y.begin(), y.end());
  y.resize(unique(y.begin(), y.end()) - y.begin());
  for (long long i = 0; i < (long long)x.size() - 1; ++i) {
    g[i].push_back({i + 1, x[i + 1] - x[i]});
    g[i + 1].push_back({i, x[i + 1] - x[i]});
  }
  for (long long i = 0; i < (long long)y.size() - 1; ++i) {
    g[i + C].push_back({i + C + 1, y[i + 1] - y[i]});
    g[i + C + 1].push_back({i + C, y[i + 1] - y[i]});
  }
  for (long long i = 0; i < m; ++i) {
    long long X = goo[i].first, Y = goo[i].second;
    long long a = lower_bound(x.begin(), x.end(), X) - x.begin(),
              b = lower_bound(y.begin(), y.end(), Y) - y.begin() + C;
    g[a].push_back({b, 0});
    g[b].push_back({a, 0});
    g[S].push_back({a, abs(s.first - X)});
    g[S].push_back({b, abs(s.second - Y)});
    g[a].push_back(
        {F, abs(goo[i].first - f.first) + abs(goo[i].second - f.second)});
    g[b].push_back(
        {F, abs(goo[i].first - f.first) + abs(goo[i].second - f.second)});
  }
  g[S].push_back({F, abs(f.first - s.first) + abs(f.second - s.second)});
  g[F].push_back({S, abs(f.first - s.first) + abs(f.second - s.second)});
  cout << Dijkstra() << '\n';
}
