#include <bits/stdc++.h>
using namespace std;
struct FastIO {
  FastIO() {
    srand(time(NULL));
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(12);
  };
} fastIO_;
template <typename T1, typename T2>
inline ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T, size_t N>
inline ostream &operator<<(ostream &os, const array<T, N> &a) {
  os << "[";
  int cnt = 0;
  for (auto &val : a) {
    if (cnt++) os << ", ";
    os << val;
  }
  os << "]";
  return os;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  int cnt = 0;
  for (auto &val : v) {
    if (cnt++) os << ", ";
    os << val;
  }
  return os << "]";
}
template <typename T>
inline ostream &operator<<(ostream &os, const set<T> &v) {
  os << "{";
  int cnt = 0;
  for (auto &val : v) {
    if (cnt++) os << ", ";
    os << val;
  }
  return os << "}";
}
template <typename T>
inline ostream &operator<<(ostream &os, const multiset<T> &v) {
  os << "{";
  int cnt = 0;
  for (auto &val : v) {
    if (cnt++) os << ", ";
    os << val;
  }
  return os << "}";
}
template <typename T1, typename T2>
inline ostream &operator<<(ostream &os, const map<T1, T2> &v) {
  os << "[";
  int cnt = 0;
  for (auto &val : v) {
    if (cnt++) os << ", ";
    os << val;
  }
  return os << "]";
}
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, 1, -1};
template <class T>
inline bool umin(T &a, const T b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
inline bool umax(T &a, const T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
struct DSU {
  int n;
  int p[100005];
  void init(int _n) {
    n = _n;
    for (int i = 0; i < n; i++) {
      p[i] = i;
    }
  }
  int find(int x) {
    int r = x;
    while (p[r] != r) r = p[r];
    for (int i = x; p[i] != r;) {
      int j = p[i];
      p[i] = r;
      i = j;
    }
    return r;
  }
  void join(int x, int y) {
    x = find(x);
    y = find(y);
    p[y] = x;
  }
  int count() {
    unordered_set<int> nodes;
    for (int i = 0; i < n; i++) nodes.insert(find(i));
    return ((int)(nodes).size());
  }
} dsu;
int n, m;
int sx, sy, fx, fy;
pair<int, int> p[100006];
int solve() {
  cin >> sx >> sy >> fx >> fy;
  long long ans = (long long)abs(sx - fx) + (long long)abs(sy - fy);
  map<int, vector<int>> xps;
  map<int, vector<int>> yps;
  for (int i = 0; i < (m); i++) {
    cin >> p[i].first >> p[i].second;
    xps[p[i].first].push_back(i);
    yps[p[i].second].push_back(i);
  }
  dsu.init(m);
  auto joinPoints = [&](map<int, vector<int>> &points) {
    for (const auto &[_, ids] : points) {
      for (int j = 1; j < ((int)(ids).size()); j++) {
        int u = dsu.find(ids[0]);
        int v = dsu.find(ids[j]);
        dsu.join(u, v);
      }
    }
  };
  joinPoints(xps);
  joinPoints(yps);
  vector<vector<pair<int, long long>>> g(m + 2);
  auto addEdge = [&](int u, int v, long long w) { g[u].emplace_back(v, w); };
  int s = m, t = m + 1;
  for (int i = 0; i < (m); i++) {
    int id = dsu.find(i);
    int d = min(abs(sx - p[i].first), abs(sy - p[i].second));
    addEdge(s, id, d);
    long long d2 =
        (long long)abs(fx - p[i].first) + (long long)abs(fy - p[i].second);
    addEdge(id, t, d2);
  }
  auto addEdgeBetweenPoints = [&](map<int, vector<int>> &points) {
    if (((int)(points).size()) <= 1) return;
    auto pre = points.begin();
    auto cur = next(pre);
    while (cur != points.end()) {
      int ru = dsu.find(pre->second[0]);
      int rv = dsu.find(cur->second[0]);
      if (ru != rv) {
        addEdge(ru, rv, abs(pre->first - cur->first));
        addEdge(rv, ru, abs(pre->first - cur->first));
      }
      pre = cur;
      cur = next(pre);
    }
  };
  addEdgeBetweenPoints(xps);
  addEdgeBetweenPoints(yps);
  vector<long long> dis(m + 2, LLONG_MAX);
  vector<bool> inQueue(m + 2, 0);
  dis[s] = 0;
  deque<int> dq;
  dq.push_back(s);
  inQueue[s] = 1;
  while (!dq.empty()) {
    int u = dq.front();
    dq.pop_front();
    inQueue[u] = 0;
    for (auto &pr : g[u]) {
      int v = pr.first;
      long long w = pr.second;
      if (umin(dis[v], dis[u] + w)) {
        if (!inQueue[v]) {
          dq.push_back(v);
          inQueue[v] = 1;
        }
      }
    }
  }
  return min(ans, dis[t]);
}
void solve(int _cas) { cout << solve() << endl; }
int main() {
  while (cin >> n >> m) solve(1);
}
