#include <bits/stdc++.h>
using namespace std;
long long n, m, sx, sy, ex, ey, a, b;
vector<pair<int, long long>> node[100001];
vector<pair<long long, int>> X, Y;
vector<long long> dist;
vector<bool> done;
int mulMod(long long, long long);
int addMod(int, int);
void readArray(int *, int);
void printArray(int *, int);
void addEdgesFromStart() {
  for (int i = 0; i < m; i++) {
    long long w = min(abs(sx - X[i].first), abs(sy - Y[i].first));
    node[0].push_back({X[i].second, w});
  }
}
void addEdgesToEnd() {
  for (int i = 0; i < m; i++) {
    long long w = abs(ex - X[i].first) + abs(ey - Y[i].first);
    node[X[i].second].push_back({m + 1, w});
  }
  long long w = abs(ex - sx) + abs(ey - sy);
  node[0].push_back({m + 1, w});
}
void addEdges(vector<pair<long long, int>> &coord) {
  for (int i = 1; i < coord.size(); i++) {
    int id1 = coord[i - 1].second, id2 = coord[i].second;
    long long w = coord[i].first - coord[i - 1].first;
    node[id1].push_back({id2, w});
    node[id2].push_back({id1, w});
  }
}
struct comp {
  bool operator()(const pair<long long, int> &x,
                  const pair<long long, int> &y) {
    return (x.first > y.first);
  }
};
int main() {
  cin >> n >> m;
  cin >> sx >> sy >> ex >> ey;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    X.push_back({a, i});
    Y.push_back({b, i});
  }
  addEdgesFromStart();
  addEdgesToEnd();
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  addEdges(X);
  addEdges(Y);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, comp> pq;
  dist.resize(m + 2, LONG_MAX);
  done.resize(m + 2, false);
  dist[0] = 0;
  pq.push({dist[0], 0});
  while (!pq.empty()) {
    pair<long long, int> curr = pq.top();
    pq.pop();
    if (curr.second == m + 1) {
      dist[m + 1] = curr.first;
      break;
    }
    if (done[curr.second]) continue;
    int id = curr.second;
    long long w = curr.first;
    done[id] = true;
    dist[id] = w;
    for (auto edge : node[id])
      if (dist[edge.first] > w + edge.second)
        pq.push({w + edge.second, edge.first});
  }
  cout << dist[m + 1] << endl;
  return 0;
}
int mulMod(long long a, long long b) {
  a *= b;
  a %= 1000000007;
  return (int)a;
}
int addMod(int a, int b) {
  long long c = a + b;
  if (c >= 1000000007) {
    c -= 1000000007;
  }
  return (int)c;
}
void readArray(int *nums, int n) {
  for (int i = 0; i < n; i++) cin >> nums[i];
}
void printArray(int *nums, int n) {
  for (int i = 0; i < n; i++) cout << nums[i] << " ";
  cout << endl;
}
