#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > v, v1[100005], vx, vy;
long long int n, m, dist[100005];
set<pair<long long int, int> > s;
long long int f(int a, int b) {
  return min(abs(v[a].first - v[b].first), abs(v[a].second - v[b].second));
}
void dijkstra() {
  for (int i = 0; i <= m; i++) {
    if (i) dist[i] = 1e18;
    s.insert(make_pair(dist[i], i));
  }
  while (!s.empty()) {
    long long int d = (*s.begin()).first, x = (*s.begin()).second;
    s.erase(s.begin());
    for (int i = 0; i < v1[x].size(); i++) {
      if (d + v1[x][i].second < dist[v1[x][i].first]) {
        s.erase(make_pair(dist[v1[x][i].first], v1[x][i].first));
        dist[v1[x][i].first] = d + v1[x][i].second;
        s.insert(make_pair(dist[v1[x][i].first], v1[x][i].first));
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int x1, y1, x2, y2, sol = 1e18;
  cin >> n >> m >> x1 >> y1 >> x2 >> y2;
  v.push_back(make_pair(x1, y1));
  vx.push_back(make_pair(x1, 0));
  vy.push_back(make_pair(y1, 0));
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(x, y));
    vx.push_back(make_pair(x, i + 1));
    vy.push_back(make_pair(y, i + 1));
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  for (int i = 0; i < m; i++) {
    long long int a = vx[i].second, b = vx[i + 1].second;
    v1[a].push_back(make_pair(b, f(a, b)));
    v1[b].push_back(make_pair(a, f(a, b)));
    a = vy[i].second;
    b = vy[i + 1].second;
    v1[a].push_back(make_pair(b, f(a, b)));
    v1[b].push_back(make_pair(a, f(a, b)));
  }
  dijkstra();
  for (int i = 0; i <= m; i++) {
    sol = min(sol, dist[i] + abs(v[i].first - x2) + abs(v[i].second - y2));
  }
  cout << sol;
  return 0;
}
