#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> niz[100005];
vector<pair<int, int> > graf[100005];
vector<pair<int, int> > x, y;
int sx, sy, fx, fy;
int rastojanja[100005];
bool obidjen[100005];
set<pair<int, int> > q;
void dijkstra() {
  q.insert(make_pair(0, 0));
  while (!q.empty()) {
    int t = q.begin()->second;
    int ud = q.begin()->first;
    q.erase(q.begin());
    if (obidjen[t]) continue;
    obidjen[t] = true;
    rastojanja[t] = ud;
    for (auto x : graf[t]) {
      if (obidjen[x.first]) continue;
      q.insert(make_pair(ud + x.second, x.first));
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d %d %d", &sx, &sy, &fx, &fy);
  x.push_back(make_pair(sx, 0));
  y.push_back(make_pair(sy, 0));
  niz[0].first = sx;
  niz[0].second = sy;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    x.push_back(make_pair(a, i));
    y.push_back(make_pair(b, i));
    niz[i] = make_pair(a, b);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  for (int i = 1; i < x.size(); i++) {
    graf[x[i].second].push_back(
        make_pair(x[i - 1].second, x[i].first - x[i - 1].first));
    graf[x[i - 1].second].push_back(
        make_pair(x[i].second, x[i].first - x[i - 1].first));
  }
  for (int i = 1; i < y.size(); i++) {
    graf[y[i].second].push_back(
        make_pair(y[i - 1].second, y[i].first - y[i - 1].first));
    graf[y[i - 1].second].push_back(
        make_pair(y[i].second, y[i].first - y[i - 1].first));
  }
  dijkstra();
  long long res = LLONG_MAX;
  for (int i = 0; i <= m; i++)
    res = min(res, 0ll + abs(0ll + niz[i].first - fx) +
                       abs(0ll + niz[i].second - fy) + rastojanja[i]);
  printf("%lld", res);
  return 0;
}
