#include <bits/stdc++.h>
using std::make_pair;
template <typename T>
inline T read() {
  T x = 0;
  char ch = std::getchar();
  bool f = 0;
  while (!std::isdigit(ch)) {
    f = (ch == '-');
    ch = std::getchar();
  }
  while (std::isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = std::getchar();
  }
  return f ? -x : x;
}
template <typename T>
void print(T x) {
  if (x < 0) {
    x = -x;
    std::putchar('-');
  }
  if (x < 10) {
    std::putchar(x + 48);
    return;
  }
  print<T>(x / 10);
  std::putchar(x % 10 + 48);
  return;
}
namespace Solution {
using std::cin;
using std::cout;
using std::deque;
using std::endl;
using std::map;
using std::pair;
using std::queue;
using std::set;
using std::vector;
const int N = 204001, mod = 1e9 + 7;
pair<int, int> p[N];
int n, m, sx, sy, fx, fy, inx[N], iny[N], posx[N], posy[N], dis[N];
bool vis[N];
long long ans;
bool cmpx(int x, int y) { return p[x].first < p[y].first; }
bool cmpy(int x, int y) { return p[x].second < p[y].second; }
void Fakemain() {
  n = read<int>();
  m = read<int>();
  sx = read<int>(), sy = read<int>(), fx = read<int>(), fy = read<int>();
  for (int i = 1; i <= m; ++i)
    p[i].first = read<int>(), p[i].second = read<int>();
  for (int i = 1; i <= m; ++i) inx[i] = i, iny[i] = i;
  std::sort(inx + 1, inx + 1 + m, cmpx);
  std::sort(iny + 1, iny + 1 + m, cmpy);
  for (int i = 1; i <= m; ++i) posx[inx[i]] = i, posy[iny[i]] = i;
  ans = abs(sx - fx) + abs(sy - fy);
  std::priority_queue<pair<int, int>, vector<pair<int, int> >,
                      std::greater<pair<int, int> > >
      Q;
  for (int i = 1; i <= m; ++i)
    Q.push(make_pair(
        dis[i] = std::min(abs(sx - p[i].first), abs(sy - p[i].second)), i));
  while (!Q.empty()) {
    auto tp = Q.top();
    Q.pop();
    if (vis[tp.second]) continue;
    vis[tp.second] = 1;
    ans = std::min(ans, 1LL * tp.first + abs(p[tp.second].second - fy) +
                            abs(p[tp.second].first - fx));
    if (inx[posx[tp.second] - 1] && !vis[inx[posx[tp.second] - 1]])
      Q.push(make_pair(
          tp.first + p[tp.second].first - p[inx[posx[tp.second] - 1]].first,
          inx[posx[tp.second] - 1]));
    if (inx[posx[tp.second] + 1] && !vis[inx[posx[tp.second] + 1]])
      Q.push(make_pair(
          tp.first - p[tp.second].first + p[inx[posx[tp.second] + 1]].first,
          inx[posx[tp.second] + 1]));
    if (iny[posy[tp.second] - 1] && !vis[iny[posy[tp.second] - 1]])
      Q.push(make_pair(
          tp.first + p[tp.second].second - p[iny[posy[tp.second] - 1]].second,
          iny[posy[tp.second] - 1]));
    if (inx[posy[tp.second] + 1] && !vis[iny[posy[tp.second] + 1]])
      Q.push(make_pair(
          tp.first - p[tp.second].second + p[iny[posy[tp.second] + 1]].second,
          iny[posy[tp.second] + 1]));
  }
  print<long long>(ans), putchar(' ');
  return;
}
}  // namespace Solution
int main(int argc, char* argv[]) {
  Solution::Fakemain();
  return 0;
}
