#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
};
vector<pair<long long, long long>> adj[100001];
map<pair<long long, long long>, long long> mp;
vector<pair<long long, long long>> values;
long long n, m;
point s, e;
bool comp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second == b.second) return a.first > b.first;
  return a.second < b.second;
}
pair<long long, long long> arr[100001];
void solve() {
  cin >> n;
  cin >> m;
  cin >> s.x >> s.y >> e.x >> e.y;
  values.resize(m);
  vector<long long> dist(1000001, 1e18);
  for (long long i = 0; i < m; i++) {
    cin >> values[i].first >> values[i].second;
    arr[i].first = values[i].first, arr[i].second = values[i].second;
    dist[i] = abs(s.x - values[i].first) + abs(s.y + values[i].second);
    mp[{values[i].first, values[i].second}] = i;
  }
  sort(values.begin(), values.end());
  for (long long i = 0; i < m - 1; i++) {
    long long id1 = mp[{values[i].first, values[i].second}];
    long long id2 = mp[{values[i + 1].first, values[i + 1].second}];
    adj[id1].push_back(
        {id2, min(abs(values[i].first - values[i + 1].first),
                  abs(values[i].second - values[i + 1].second))});
    adj[id2].push_back(
        {id1, min(abs(values[i].first - values[i + 1].first),
                  abs(values[i].second - values[i + 1].second))});
  }
  sort(values.begin(), values.end(), comp);
  for (long long i = 0; i < m - 1; i++) {
    long long id1 = mp[{values[i].first, values[i].second}];
    long long id2 = mp[{values[i + 1].first, values[i + 1].second}];
    adj[id1].push_back(
        {id2, min(abs(values[i].first - values[i + 1].first),
                  abs(values[i].second - values[i + 1].second))});
    adj[id2].push_back(
        {id1, min(abs(values[i].first - values[i + 1].first),
                  abs(values[i].second - values[i + 1].second))});
  }
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      q;
  for (long long i = 0; i < m; i++) {
    dist[mp[{values[i].first, values[i].second}]] =
        min(abs(values[i].first - s.x), abs(values[i].second - s.y));
  }
  for (long long i = 0; i < m; i++) {
    q.push({dist[i], i});
  }
  while (!q.empty()) {
    long long curnode = q.top().second;
    long long currdis = q.top().first;
    q.pop();
    if (dist[curnode] < currdis) continue;
    for (auto it : adj[curnode]) {
      if (dist[it.first] > currdis + it.second) {
        dist[it.first] = currdis + it.second;
        q.push({dist[it.first], it.first});
      }
    }
  }
  long long ans = abs(s.x - e.x) + abs(e.y - s.y);
  for (long long i = 0; i < m; i++) {
    ans =
        min(ans, dist[i] + abs(e.x - arr[i].first) + abs(e.y - arr[i].second));
  }
  cout << ans << endl;
}
int32_t main() {
  long long t = 1;
  while (t--) solve();
  return 0;
}
