#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > G[1000005];
long long odl[1000005];
pair<long long, pair<long long, long long> > t[1000005];
long long n, m, p1, p2, k1, k2, x, y;
priority_queue<pair<long long, long long> > q;
long long oo(pair<long long, pair<long long, long long> > a,
             pair<long long, pair<long long, long long> > b) {
  if (b.first <= 2)
    return abs(a.second.first - b.second.first) +
           abs(a.second.second - b.second.second);
  else
    return min(abs(a.second.first - b.second.first),
               abs(a.second.second - b.second.second));
}
bool cmp1(pair<long long, pair<long long, long long> > a,
          pair<long long, pair<long long, long long> > b) {
  if (a.second.first > b.second.first)
    return true;
  else
    return false;
}
bool cmp2(pair<long long, pair<long long, long long> > a,
          pair<long long, pair<long long, long long> > b) {
  if (a.second.second > b.second.second)
    return true;
  else
    return false;
}
void dikstra(long long s) {
  odl[s] = 0;
  q.push(make_pair(0, 1));
  while (!q.empty()) {
    long long a = q.top().second;
    q.pop();
    for (int i = 0; i < G[a].size(); i++) {
      int b = G[a][i].first;
      if (odl[b] > odl[a] + G[a][i].second) {
        odl[b] = odl[a] + G[a][i].second;
        q.push(make_pair(-odl[b], b));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> p1 >> p2 >> k1 >> k2;
  t[0] = make_pair(1, make_pair(p1, p2));
  t[1] = make_pair(2, make_pair(k1, k2));
  G[1].push_back(make_pair(2, abs(p1 - k1) + abs(p2 - k2)));
  for (int i = 2; i < m + 2; i++) {
    cin >> x >> y;
    t[i] = make_pair(i + 1, make_pair(x, y));
    G[1].push_back(make_pair(i + 1, oo(t[0], t[i])));
    G[i + 1].push_back(make_pair(2, oo(t[i], t[1])));
  }
  sort(t + 2, t + m + 2, cmp1);
  for (int i = 2; i < m + 2; i++) {
    if (i != 2) {
      G[t[i].first].push_back(make_pair(t[i - 1].first, oo(t[i], t[i - 1])));
    }
    if (i != m + 1) {
      G[t[i].first].push_back(make_pair(t[i + 1].first, oo(t[i], t[i + 1])));
    }
  }
  sort(t + 2, t + m + 2, cmp2);
  for (int i = 2; i < m + 2; i++) {
    if (i != 2) {
      G[t[i].first].push_back(make_pair(t[i - 1].first, oo(t[i], t[i - 1])));
    }
    if (i != m + 1) {
      G[t[i].first].push_back(make_pair(t[i + 1].first, oo(t[i], t[i + 1])));
    }
  }
  for (int i = 0; i < m + 5; i++) {
    odl[i] = 1000000000000000000 / 5;
  }
  dikstra(1);
  cout << odl[2];
}
