#include <bits/stdc++.h>
using namespace std;
long long dis[100009], x[100009], y[100009];
int vis[100009], n, m, sx, sy, fx, fy;
vector<pair<int, int> > a, b;
vector<pair<long long, int> > adj[100009];
multiset<pair<long long int, int> > q;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  cin >> sx >> sy >> fx >> fy;
  for (int i = 1; i <= m; i++) {
    cin >> x[i] >> y[i];
    a.push_back({x[i], i});
    b.push_back({y[i], i});
  }
  x[0] = sx;
  y[0] = sy;
  a.push_back({x[0], 0});
  b.push_back({y[0], 0});
  x[m + 1] = fx;
  y[m + 1] = fy;
  q.insert({0, 0});
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < m; i++) {
    int dist2 = a[i + 1].first - a[i].first;
    adj[a[i].second].push_back({dist2, a[i + 1].second});
    if (i > 0) {
      dist2 = a[i].first - a[i - 1].first;
      adj[a[i].second].push_back({dist2, a[i - 1].second});
    }
  }
  if (m > 0) {
    adj[a[m].second].push_back({a[m].first - a[m - 1].first, a[m - 1].second});
  }
  for (int i = 0; i < m; i++) {
    int dist2 = b[i + 1].first - b[i].first;
    adj[b[i].second].push_back({dist2, b[i + 1].second});
    if (i > 0) {
      dist2 = b[i].first - b[i - 1].first;
      adj[b[i].second].push_back({dist2, b[i - 1].second});
    }
  }
  if (m > 0) {
    adj[b[m].second].push_back({b[m].first - b[m - 1].first, b[m - 1].second});
  }
  for (int i = 0; i <= m; i++) {
    int dist2 = abs(x[i] - x[m + 1]) + abs(y[i] - y[m + 1]);
    adj[i].push_back({dist2, m + 1});
  }
  while (!q.empty()) {
    auto it = q.begin();
    int dist1 = it->first;
    int ele = it->second;
    q.erase(q.begin());
    if (vis[ele]) continue;
    vis[ele] = 1;
    dis[ele] = dist1;
    for (int i = 0; i < adj[ele].size(); i++) {
      if (!vis[adj[ele][i].second])
        q.insert({dis[ele] + adj[ele][i].first, adj[ele][i].second});
    }
  }
  cout << dis[m + 1];
  return 0;
}
