#include <bits/stdc++.h>
using namespace std;
const int N = int(3e5) + 12, mod = int(1e9) + 7;
int n, m;
int sx, sy, fx, fy;
vector<pair<int, int> > g[N];
long long d[N];
pair<int, pair<int, int> > p[N];
bool cmp1(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.second.first < b.second.first;
}
bool cmp2(pair<int, pair<int, int> > a, pair<int, pair<int, int> > b) {
  return a.second.second < b.second.second;
}
void add(int u, int v, int x) { g[u].push_back(make_pair(v, x)); }
void solve() {
  scanf("%d%d", &n, &m);
  scanf("%d%d%d%d", &sx, &sy, &fx, &fy);
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(i, 0, abs(sx - x) + abs(sy - y));
    add(i, m + 1, abs(fx - x) + abs(fy - y));
    add(0, i, min(abs(sx - x), abs(sy - y)));
    add(m + 1, i, (abs(fx - x), abs(fy - y)));
    p[i] = make_pair(i, make_pair(x, y));
  }
  sort(p + 1, p + m + 1, cmp1);
  for (int i = 2; i <= m; i++) {
    add(p[i - 1].first, p[i].first,
        min(abs(p[i].second.first - p[i - 1].second.first),
            abs(p[i].second.second - p[i - 1].second.second)));
    add(p[i].first, p[i - 1].first,
        min(abs(p[i].second.first - p[i - 1].second.first),
            abs(p[i].second.second - p[i - 1].second.second)));
  }
  add(0, m + 1, abs(sx - fx) + abs(sy - fy));
  sort(p + 1, p + m + 1, cmp2);
  for (int i = 2; i <= m; i++) {
    add(p[i - 1].first, p[i].first,
        min(abs(p[i].second.first - p[i - 1].second.first),
            abs(p[i].second.second - p[i - 1].second.second)));
    add(p[i].first, p[i - 1].first,
        min(abs(p[i].second.first - p[i - 1].second.first),
            abs(p[i].second.second - p[i - 1].second.second)));
  }
  set<pair<long long, int> > st;
  m++;
  for (int i = 1; i <= m; i++) d[i] = (long long)(1e12);
  d[0] = 0;
  st.insert(make_pair(0, 0));
  while (!st.empty()) {
    int v = (*st.begin()).second;
    st.erase(st.begin());
    for (auto to : g[v]) {
      if (d[to.first] > d[v] + to.second) {
        st.erase(make_pair(d[to.first], to.first));
        d[to.first] = d[v] + to.second;
        st.insert(make_pair(d[to.first], to.first));
      }
    }
  }
  cout << d[m];
}
int main() {
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
