Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.Let's represent the city as an area of $$$n \times n$$$ square blocks. Yura needs to move from the block with coordinates $$$(s_x,s_y)$$$ to the block with coordinates $$$(f_x,f_y)$$$. In one minute Yura can move to any neighboring by side block; in other words, he can move in four directions. Also, there are $$$m$$$ instant-movement locations in the city. Their coordinates are known to you and Yura. Yura can move to an instant-movement location in no time if he is located in a block with the same coordinate $$$x$$$ or with the same coordinate $$$y$$$ as the location.Help Yura to find the smallest time needed to get home.

The first line contains two integers $$$n$$$ and $$$m$$$ — the size of the city and the number of instant-movement locations ($$$1 \le n \le 10^9$$$, $$$0 \le m \le 10^5$$$). The next line contains four integers $$$s_x$$$ $$$s_y$$$ $$$f_x$$$ $$$f_y$$$ — the coordinates of Yura's initial position and the coordinates of his home ($$$ 1 \le s_x, s_y, f_x, f_y \le n$$$). Each of the next $$$m$$$ lines contains two integers $$$x_i$$$ $$$y_i$$$ — coordinates of the $$$i$$$-th instant-movement location ($$$1 \le x_i, y_i \le n$$$).

In the only line print the minimum time required to get home.

NoteIn the first example Yura needs to reach $$$(5, 5)$$$ from $$$(1, 1)$$$. He can do that in $$$5$$$ minutes by first using the second instant-movement location (because its $$$y$$$ coordinate is equal to Yura's $$$y$$$ coordinate), and then walking $$$(4, 1) \to (4, 2) \to (4, 3) \to (5, 3) \to (5, 4) \to (5, 5)$$$.

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new Heap(m * 4 + 1)
  // let t = new SplayTree()
  d.forEach(v => t.push(v.d, v.i))
  // t.print()
  while (t.size) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.push(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    [this.h[1], this.h[this.size]] = [this.h[this.size], this.h[1]];
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  // let t = new AVLTree()
  let t = new SplayTree()
  d.forEach(v => t.insert(v.d, v.i))
  // t.print()
  while (t.root) {
    let v = d[t.remove(-1e10).value];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

var AVLTree = (function () {
  /**
   * Prints tree horizontally
   * @param  {Node}                       root
   * @param  {Function(node:Node):String} [printNode]
   * @return {String}
   */
  function print(root, printNode) {
    if (printNode === void 0) printNode = function (n) { return n.key; };

    var out = [];
    row(root, '', true, function (v) { return out.push(v); }, printNode);
    return out.join('');
  }

  /**
   * Is the tree balanced (none of the subtrees differ in height by more than 1)
   * @param  {Node}    root
   * @return {Boolean}
   */
  function isBalanced(root) {
    if (root === null) { return true; } // If node is empty then return true

    // Get the height of left and right sub trees
    var lh = height(root.left);
    var rh = height(root.right);

    if (Math.abs(lh - rh) <= 1 &&
      isBalanced(root.left) &&
      isBalanced(root.right)) { return true; }

    // If we reach here then tree is not height-balanced
    return false;
  }

  /**
   * The function Compute the 'height' of a tree.
   * Height is the number of nodes along the longest path
   * from the root node down to the farthest leaf node.
   *
   * @param  {Node} node
   * @return {Number}
   */
  function height(node) {
    return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
  }

  function loadRecursive(parent, keys, values, start, end) {
    var size = end - start;
    if (size > 0) {
      var middle = start + Math.floor(size / 2);
      var key = keys[middle];
      var data = values[middle];
      var node = { key: key, data: data, parent: parent };
      node.left = loadRecursive(node, keys, values, start, middle);
      node.right = loadRecursive(node, keys, values, middle + 1, end);
      return node;
    }
    return null;
  }

  function markBalance(node) {
    if (node === null) { return 0; }
    var lh = markBalance(node.left);
    var rh = markBalance(node.right);

    node.balanceFactor = lh - rh;
    return Math.max(lh, rh) + 1;
  }

  function sort(keys, values, left, right, compare) {
    if (left >= right) { return; }

    // eslint-disable-next-line no-bitwise
    var pivot = keys[(left + right) >> 1];
    var i = left - 1;
    var j = right + 1;

    // eslint-disable-next-line no-constant-condition
    while (true) {
      do { i++; } while (compare(keys[i], pivot) < 0);
      do { j--; } while (compare(keys[j], pivot) > 0);
      if (i >= j) { break; }

      var tmp = keys[i];
      keys[i] = keys[j];
      keys[j] = tmp;

      tmp = values[i];
      values[i] = values[j];
      values[j] = tmp;
    }

    sort(keys, values, left, j, compare);
    sort(keys, values, j + 1, right, compare);
  }

  // function createNode (parent, left, right, height, key, data) {
  //   return { parent, left, right, balanceFactor: height, key, data };
  // }

  /**
   * @typedef {{
   *   parent:        ?Node,
   *   left:          ?Node,
   *   right:         ?Node,
   *   balanceFactor: number,
   *   key:           Key,
   *   data:          Value
   * }} Node
   */

  /**
   * @typedef {*} Key
   */

  /**
   * @typedef {*} Value
   */

  /**
   * Default comparison function
   * @param {Key} a
   * @param {Key} b
   * @returns {number}
   */
  function DEFAULT_COMPARE(a, b) { return a > b ? 1 : a < b ? -1 : 0; }

  /**
   * Single left rotation
   * @param  {Node} node
   * @return {Node}
   */
  function rotateLeft(node) {
    var rightNode = node.right;
    node.right = rightNode.left;

    if (rightNode.left) { rightNode.left.parent = node; }

    rightNode.parent = node.parent;
    if (rightNode.parent) {
      if (rightNode.parent.left === node) {
        rightNode.parent.left = rightNode;
      } else {
        rightNode.parent.right = rightNode;
      }
    }

    node.parent = rightNode;
    rightNode.left = node;

    node.balanceFactor += 1;
    if (rightNode.balanceFactor < 0) {
      node.balanceFactor -= rightNode.balanceFactor;
    }

    rightNode.balanceFactor += 1;
    if (node.balanceFactor > 0) {
      rightNode.balanceFactor += node.balanceFactor;
    }
    return rightNode;
  }

  function rotateRight(node) {
    var leftNode = node.left;
    node.left = leftNode.right;
    if (node.left) { node.left.parent = node; }

    leftNode.parent = node.parent;
    if (leftNode.parent) {
      if (leftNode.parent.left === node) {
        leftNode.parent.left = leftNode;
      } else {
        leftNode.parent.right = leftNode;
      }
    }

    node.parent = leftNode;
    leftNode.right = node;

    node.balanceFactor -= 1;
    if (leftNode.balanceFactor > 0) {
      node.balanceFactor -= leftNode.balanceFactor;
    }

    leftNode.balanceFactor -= 1;
    if (node.balanceFactor < 0) {
      leftNode.balanceFactor += node.balanceFactor;
    }

    return leftNode;
  }

  // function leftBalance (node) {
  //   if (node.left.balanceFactor === -1) rotateLeft(node.left);
  //   return rotateRight(node);
  // }

  // function rightBalance (node) {
  //   if (node.right.balanceFactor === 1) rotateRight(node.right);
  //   return rotateLeft(node);
  // }

  var AVLTree = function AVLTree(comparator, noDuplicates) {
    if (noDuplicates === void 0) noDuplicates = false;

    this._comparator = comparator || DEFAULT_COMPARE;
    this._root = null;
    this._size = 0;
    this._noDuplicates = !!noDuplicates;
  };

  var prototypeAccessors = { size: { configurable: true } };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.destroy = function destroy() {
    return this.clear();
  };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.clear = function clear() {
    this._root = null;
    this._size = 0;
    return this;
  };

  /**
   * Number of nodes
   * @return {number}
   */
  prototypeAccessors.size.get = function () {
    return this._size;
  };

  /**
   * Whether the tree contains a node with the given key
   * @param{Key} key
   * @return {boolean} true/false
   */
  AVLTree.prototype.contains = function contains(key) {
    if (this._root) {
      var node = this._root;
      var comparator = this._comparator;
      while (node) {
        var cmp = comparator(key, node.key);
        if (cmp === 0) { return true; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    }
    return false;
  };

  /* eslint-disable class-methods-use-this */

  /**
   * Successor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.next = function next(node) {
    var successor = node;
    if (successor) {
      if (successor.right) {
        successor = successor.right;
        while (successor.left) { successor = successor.left; }
      } else {
        successor = node.parent;
        while (successor && successor.right === node) {
          node = successor; successor = successor.parent;
        }
      }
    }
    return successor;
  };

  /**
   * Predecessor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.prev = function prev(node) {
    var predecessor = node;
    if (predecessor) {
      if (predecessor.left) {
        predecessor = predecessor.left;
        while (predecessor.right) { predecessor = predecessor.right; }
      } else {
        predecessor = node.parent;
        while (predecessor && predecessor.left === node) {
          node = predecessor;
          predecessor = predecessor.parent;
        }
      }
    }
    return predecessor;
  };
  /* eslint-enable class-methods-use-this */

  /**
   * Callback for forEach
   * @callback forEachCallback
   * @param {Node} node
   * @param {number} index
   */

  /**
   * @param{forEachCallback} callback
   * @return {AVLTree}
   */
  AVLTree.prototype.forEach = function forEach(callback) {
    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      // Reach the left most Node of the current Node
      if (current) {
        // Place pointer to a tree node on the stack
        // before traversing the node's left subtree
        s.push(current);
        current = current.left;
      } else {
        // BackTrack from the empty subtree and visit the Node
        // at the top of the stack; however, if the stack is
        // empty you are done
        if (s.length > 0) {
          current = s.pop();
          callback(current, i++);

          // We have visited the node and its left
          // subtree. Now, it's right subtree's turn
          current = current.right;
        } else { done = true; }
      }
    }
    return this;
  };

  AVLTree.prototype.range = function range(low, high, fn, ctx) {
    var this$1 = this;

    var Q = [];
    var compare = this._comparator;
    var node = this._root, cmp;

    while (Q.length !== 0 || node) {
      if (node) {
        Q.push(node);
        node = node.left;
      } else {
        node = Q.pop();
        cmp = compare(node.key, high);
        if (cmp > 0) {
          break;
        } else if (compare(node.key, low) >= 0) {
          if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
        }
        node = node.right;
      }
    }
    return this;
  };

  /**
   * Returns all keys in order
   * @return {Array<Key>}
   */
  AVLTree.prototype.keys = function keys() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.key);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  AVLTree.prototype.values = function values() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.data);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  /**
   * Returns node at given index
   * @param{number} index
   * @return {?Node}
   */
  AVLTree.prototype.at = function at(index) {
    // removed after a consideration, more misleading than useful
    // index = index % this.size;
    // if (index < 0) index = this.size - index;

    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          if (i === index) { return current; }
          i++;
          current = current.right;
        } else { done = true; }
      }
    }
    return null;
  };

  /**
   * Returns node with the minimum key
   * @return {?Node}
   */
  AVLTree.prototype.minNode = function minNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node;
  };

  /**
   * Returns node with the max key
   * @return {?Node}
   */
  AVLTree.prototype.maxNode = function maxNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node;
  };

  /**
   * Min key
   * @return {?Key}
   */
  AVLTree.prototype.min = function min() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node.key;
  };

  /**
   * Max key
   * @return {?Key}
   */
  AVLTree.prototype.max = function max() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node.key;
  };

  /**
   * @return {boolean} true/false
   */
  AVLTree.prototype.isEmpty = function isEmpty() {
    return !this._root;
  };

  /**
   * Removes and returns the node with smallest key
   * @return {?Node}
   */
  AVLTree.prototype.pop = function pop() {
    var node = this._root, returnValue = null;
    if (node) {
      while (node.left) { node = node.left; }
      returnValue = { key: node.key, data: node.data };
      this.remove(node.key);
    }
    return returnValue;
  };

  /**
   * Find node by key
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.find = function find(key) {
    var root = this._root;
    // if (root === null)  return null;
    // if (key === root.key) return root;

    var subtree = root, cmp;
    var compare = this._comparator;
    while (subtree) {
      cmp = compare(key, subtree.key);
      if (cmp === 0) { return subtree; }
      else if (cmp < 0) { subtree = subtree.left; }
      else { subtree = subtree.right; }
    }

    return null;
  };

  /**
   * Insert a node into the tree
   * @param{Key} key
   * @param{Value} [data]
   * @return {?Node}
   */
  AVLTree.prototype.insert = function insert(key, data) {
    var this$1 = this;

    if (!this._root) {
      this._root = {
        parent: null, left: null, right: null, balanceFactor: 0,
        key: key, data: data
      };
      this._size++;
      return this._root;
    }

    var compare = this._comparator;
    var node = this._root;
    var parent = null;
    var cmp = 0;

    if (this._noDuplicates) {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp === 0) { return null; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    } else {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp <= 0) { node = node.left; } //return null;
        else { node = node.right; }
      }
    }

    var newNode = {
      left: null,
      right: null,
      balanceFactor: 0,
      parent: parent, key: key, data: data
    };
    var newRoot;
    if (cmp <= 0) { parent.left = newNode; }
    else { parent.right = newNode; }

    while (parent) {
      cmp = compare(parent.key, key);
      if (cmp < 0) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor === 0) { break; }
      else if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      }
      parent = parent.parent;
    }

    this._size++;
    return newNode;
  };

  /**
   * Removes the node from the tree. If not found, returns null.
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.remove = function remove(key) {
    var this$1 = this;

    if (!this._root) { return null; }

    var node = this._root;
    var compare = this._comparator;
    var cmp = 0;

    while (node) {
      cmp = compare(key, node.key);
      if (cmp === 0) { break; }
      else if (cmp < 0) { node = node.left; }
      else { node = node.right; }
    }
    if (!node) { return null; }

    var returnValue = node.key;
    var max, min;

    if (node.left) {
      max = node.left;

      while (max.left || max.right) {
        while (max.right) { max = max.right; }

        node.key = max.key;
        node.data = max.data;
        if (max.left) {
          node = max;
          max = max.left;
        }
      }

      node.key = max.key;
      node.data = max.data;
      node = max;
    }

    if (node.right) {
      min = node.right;

      while (min.left || min.right) {
        while (min.left) { min = min.left; }

        node.key = min.key;
        node.data = min.data;
        if (min.right) {
          node = min;
          min = min.right;
        }
      }

      node.key = min.key;
      node.data = min.data;
      node = min;
    }

    var parent = node.parent;
    var pp = node;
    var newRoot;

    while (parent) {
      if (parent.left === pp) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      }

      if (parent.balanceFactor === -1 || parent.balanceFactor === 1) { break; }

      pp = parent;
      parent = parent.parent;
    }

    if (node.parent) {
      if (node.parent.left === node) { node.parent.left = null; }
      else { node.parent.right = null; }
    }

    if (node === this._root) { this._root = null; }

    this._size--;
    return returnValue;
  };

  /**
   * Bulk-load items
   * @param{Array<Key>}keys
   * @param{Array<Value>}[values]
   * @return {AVLTree}
   */
  AVLTree.prototype.load = function load(keys, values, presort) {
    if (keys === void 0) keys = [];
    if (values === void 0) values = [];

    if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
    var size = keys.length;
    if (presort) { sort(keys, values, 0, size - 1, this._comparator); }
    this._root = loadRecursive(null, keys, values, 0, size);
    markBalance(this._root);
    this._size = size;
    return this;
  };

  /**
   * Returns true if the tree is balanced
   * @return {boolean}
   */
  AVLTree.prototype.isBalanced = function isBalanced$1() {
    return isBalanced(this._root);
  };

  /**
   * String representation of the tree - primitive horizontal print-out
   * @param{Function(Node):string} [printNode]
   * @return {string}
   */
  AVLTree.prototype.toString = function toString(printNode) {
    return print(this._root, printNode);
  };

  Object.defineProperties(AVLTree.prototype, prototypeAccessors);

  AVLTree.default = AVLTree;

  return AVLTree;

})();

class Node {
  left; right; key; value;
  constructor(key, value) {
    this.key = key;
    this.value = value;
  }
  update() {
  }
  toString() {
    return (this.left ? this.left.toString() + ' ' : '') + `(${this.key},${this.value})` + (this.right ? ' ' + this.right.toString() : '')
  }
}

class SplayTree {
  root;
  constructor(node) {
    this.root = node;
  }

  uptree(x, p, g) {
    if (!g) {
      // lazy update p, x
      if (p.left == x) {
        p.left = x.right;
        x.right = p;
      } else {
        p.right = x.left;
        x.left = p;
      }
      p.update(); x.update();
      return x;
    }
    // lazy update g, p, x
    if (g.left == p && p.left == x) {
      g.left = p.right;
      p.right = g;
      p.left = x.right;
      x.right = p;
    } else if (g.right == p && p.right == x) {
      g.right = p.left;
      p.left = g;
      p.right = x.left;
      x.left = p;
    } else if (g.left == p) {
      p.right = x.left;
      x.left = p;
      g.left = x.right;
      x.right = g;
    } else {
      p.left = x.right;
      x.right = p;
      g.right = x.left;
      x.left = g;
    }
    g.update(); p.update(); x.update();
    return x;
  }

  splay(trace) {
    var x = trace.pop();
    while (true) {
      var p = trace.pop();
      var g = trace.pop();
      if (!p) return this.root = x;
      if (!g || !trace.length) return this.root = this.uptree(x, p, g);
      if (trace[trace.length - 1].left == g) trace[trace.length - 1].left = x = this.uptree(x, p, g);
      else trace[trace.length - 1].right = x = this.uptree(x, p, g);
    }
  }

  insert(key, value) {
    if (!this.root) return this.root = new Node(key, value);
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      cur = key < cur.key ? cur.left : cur.right;
    }
    cur = trace[trace.length - 1];
    if (key < cur.key) trace.push(cur.left = new Node(key, value));
    else trace.push(cur.right = new Node(key, value));
    this.splay(trace);
  }

  join(tree) {
    if (!this.root) return this.root = tree.root;
    var trace = [this.root];
    var cur = this.root;
    while (cur.right) trace.push(cur = cur.right);
    this.splay(trace);
    this.root.right = tree.root;
    this.root.update();
  }

  remove(key) {
    if (!this.root) return;
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      if (cur.key == key) break;
      cur = key < cur.key ? cur.left : cur.right;
    }
    // if (trace[trace.length - 1].key != key) return;
    this.splay(trace);
    var node = this.root;
    var tree = new SplayTree(this.root.right);
    this.root = this.root.left;
    this.join(tree);
    return node;
  }

  load(nodes) {
    if (!nodes.length) return;
    this.root = nodes[0];
    let s = 1, k = 1;
    while (s < nodes.length) {
      let end = Math.min(s + k, nodes.length - 1);
      for (let i = end - 1; i >= s; i--) {
        nodes[i].right = nodes[i + 1];
        nodes[i].update();
      }
      this.root = nodes[s];
      this.root.left = nodes[s - k];
      this.root.update()
      s += ++k;
    }
  }

  print() {
    console.log(this.root ? this.root.toString() : undefined);
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new Heap(m * 4 + 1)
  // let t = new SplayTree()
  d.forEach(v => v.h = t.push(v.d, v.i))
  // t.print()
  // log(d)
  while (t.size) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        // t.push(v.d + e.d, e.v.i)
        t.update(d[e.v.i].h.i, d[e.v.i].d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  swap(i, j) {
    this.h[i].i = j; this.h[j].i = i;
    [this.h[i], this.h[j]] = [this.h[j], this.h[i]];
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.swap(i, i2)
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    this.swap(1, this.size);
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
  update(i, key, data) {
    this.h[i].key = key;
    this.h[i].data = data;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) return this.upHeap(i);
    return this.downHeap(i);
  }
  remove(i) {
    this.swap(i, this.size);
    this.size--;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) this.upHeap(i);
    else this.downHeap(i);
    return this.h[this.size + 1];
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new Heap(m * 4 + 1)
  // let t = new SplayTree()
  d.forEach(v => v.h = t.push(v.d, v.i))
  // t.print()
  // log(d)
  while (t.size) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        // t.push(v.d + e.d, e.v.i)
        t.update(d[e.v.i].h.i, d[e.v.i].d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    [this.h[1], this.h[this.size]] = [this.h[this.size], this.h[1]];
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
  update(i, key, data) {
    this.h[i].key = key;
    this.h[i].data = data;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) return this.upHeap(i);
    return this.downHeap(i);
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new SkipList(20)
  // let t = new SplayTree()
  d.forEach(v => t.insert(v.d, v.i))
  // t.print()
  while (t.head.next[0]) {
    let v = d[t.remove(-1).data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Node {
  next; key; data;
  constructor(key, data, MAX_LAYER) {
    this.key = key;
    this.data = data;
    this.next = Array(MAX_LAYER);
  }
}

class SkipList {
  head; MAX_LAYER; maxNode;
  constructor(MAX_LAYER = 3) {
    this.MAX_LAYER = MAX_LAYER;
    this.head = new Node(-1e10, MAX_LAYER);
    for (let i = 0; i < MAX_LAYER; i++)this.head.next[i] = null;
  }

  insert(key, data) {
    var cur = this.head;
    var layer = this.MAX_LAYER - 1;
    var trace = [];
    while (layer >= 0) {
      while (cur.next[layer] && cur.next[layer].key < key) {
        cur = cur.next[layer];
      }
      if (trace[trace.length - 1] != cur) trace.push(cur);
      layer--;
    }
    var node = new Node(key, data);
    if (this.maxNode && this.maxNode.key < key) this.maxNode = node;
    node.next[0] = cur.next[0];
    cur.next[0] = node;
    for (let i = 1; i < this.MAX_LAYER; i++) {
      if (Math.random() < 0.5) break;
      while (cur.next[i] === undefined) {
        cur = trace.pop();
      }
      node.next[i] = cur.next[i];
      cur.next[i] = node;
    }
  }

  remove(key) {
    if (this.maxNode && this.maxNode.key == key) this.maxNode = undefined;
    var cur = this.head;
    var layer = this.MAX_LAYER - 1;
    var trace = [];
    while (layer >= 0) {
      while (cur.next[layer] && cur.next[layer].key < key) {
        cur = cur.next[layer];
      }
      if (trace[trace.length - 1] != cur) trace.push(cur);
      layer--;
    }
    var node = cur.next[0];
    // if (!node || node.key != key) return;
    cur.next[0] = node.next[0];
    for (let i = 1; i < this.MAX_LAYER; i++) {
      if (node.next[i] === undefined) break;
      while (cur.next[i] != node) {
        cur = trace.pop();
      }
      cur.next[i] = node.next[i];
    }
    return node;
  }

  min() {
    return this.head.next[0];
  }

  max() {
    if (this.maxNode) return this.maxNode;
    var cur = this.head;
    for (let i = this.MAX_LAYER - 1; i >= 0; i--) {
      while (cur.next[i]) cur = cur.next[i];
    }
    if (cur != this.head) this.maxNode = cur;
    return cur != this.head ? cur : undefined;
  }

  print() {
    for (let i = 0; i < this.MAX_LAYER; i++) {
      let arr = [];
      let cur = this.head.next[i];
      while (cur) {
        arr.push(cur.key);
        cur = cur.next[i];
      }
      console.log(`Layer ${i}: ${arr.join(' ')}`)
    }
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new SkipList(15)
  // let t = new SplayTree()
  d.forEach(v => t.insert(v.d, v.i))
  // t.print()
  while (t.head.next[0]) {
    let v = d[t.remove(-1).data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Node {
  next; key; data;
  constructor(key, data, MAX_LAYER) {
    this.key = key;
    this.data = data;
    this.next = Array(MAX_LAYER);
  }
}

class SkipList {
  head; MAX_LAYER; maxNode;
  constructor(MAX_LAYER = 3) {
    this.MAX_LAYER = MAX_LAYER;
    this.head = new Node(-1e10, MAX_LAYER);
    for (let i = 0; i < MAX_LAYER; i++)this.head.next[i] = null;
  }

  insert(key, data) {
    var cur = this.head;
    var layer = this.MAX_LAYER - 1;
    var trace = [];
    while (layer >= 0) {
      while (cur.next[layer] && cur.next[layer].key < key) {
        cur = cur.next[layer];
      }
      if (trace[trace.length - 1] != cur) trace.push(cur);
      layer--;
    }
    var node = new Node(key, data);
    if (this.maxNode && this.maxNode.key < key) this.maxNode = node;
    node.next[0] = cur.next[0];
    cur.next[0] = node;
    for (let i = 1; i < this.MAX_LAYER; i++) {
      if (Math.random() < 0.5) break;
      while (cur.next[i] === undefined) {
        cur = trace.pop();
      }
      node.next[i] = cur.next[i];
      cur.next[i] = node;
    }
  }

  remove(key) {
    if (this.maxNode && this.maxNode.key == key) this.maxNode = undefined;
    var cur = this.head;
    var layer = this.MAX_LAYER - 1;
    var trace = [];
    while (layer >= 0) {
      while (cur.next[layer] && cur.next[layer].key < key) {
        cur = cur.next[layer];
      }
      if (trace[trace.length - 1] != cur) trace.push(cur);
      layer--;
    }
    var node = cur.next[0];
    // if (!node || node.key != key) return;
    cur.next[0] = node.next[0];
    for (let i = 1; i < this.MAX_LAYER; i++) {
      if (node.next[i] === undefined) break;
      while (cur.next[i] != node) {
        cur = trace.pop();
      }
      cur.next[i] = node.next[i];
    }
    return node;
  }

  min() {
    return this.head.next[0];
  }

  max() {
    if (this.maxNode) return this.maxNode;
    var cur = this.head;
    for (let i = this.MAX_LAYER - 1; i >= 0; i--) {
      while (cur.next[i]) cur = cur.next[i];
    }
    if (cur != this.head) this.maxNode = cur;
    return cur != this.head ? cur : undefined;
  }

  print() {
    for (let i = 0; i < this.MAX_LAYER; i++) {
      let arr = [];
      let cur = this.head.next[i];
      while (cur) {
        arr.push(cur.key);
        cur = cur.next[i];
      }
      console.log(`Layer ${i}: ${arr.join(' ')}`)
    }
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1].i, d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i].i, d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1].i, d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i].i, d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new Heap(m * 4 + 1)
  // let t = new SplayTree()
  d.forEach(v => v.h = t.push(v.d, v.i))
  // t.print()
  // log(d)
  while (t.size) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v].d) {
        d[e.v].d = v.d + e.d;
        // t.push(v.d + e.d, e.v.i)
        t.update(d[e.v].h.i, d[e.v].d, e.v)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Heap {
  size; comp; h; // h = {key,data,i}[]
  constructor(MAX_LENGTH = 100, comp = (a, b) => a.key < b.key) {
    this.h = Array(MAX_LENGTH);
    this.size = 0;
    this.comp = comp;
  }
  upHeap(i) {
    let i2
    while (i > 1) {
      i2 = i >> 1;
      if (this.comp(this.h[i2], this.h[i])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  downHeap(i) {
    let i2;
    while (1) {
      i2 = i << 1;
      if (i2 < this.size && this.comp(this.h[i2 | 1], this.h[i2])) i2 |= 1;
      if (i2 > this.size || this.comp(this.h[i], this.h[i2])) break;
      this.h[i2].i = i; this.h[i].i = i2;
      [this.h[i2], this.h[i]] = [this.h[i], this.h[i2]];
      i = i2;
    }
    return this.h[i];
  }
  push(key, data) {
    this.h[++this.size] = { key, data, i: this.size };
    return this.upHeap(this.size);
  }
  pop() {
    [this.h[1], this.h[this.size]] = [this.h[this.size], this.h[1]];
    this.size--;
    this.downHeap(1);
    return this.h[this.size + 1];
  }
  update(i, key, data) {
    this.h[i].key = key;
    this.h[i].data = data;
    if (i > 1 && this.comp(this.h[i], this.h[i >> 1])) return this.upHeap(i);
    return this.downHeap(i);
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new SplayTree()
  t.load(d.slice().sort((a, b) => a.d - b.d).map(v => new Node(v.d, v.i)))
  // t.print()
  while (t.root) {
    let v = d[t.remove(-1e10).value];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

class Node {
  left; right; key; value;
  constructor(key, value) {
    this.key = key;
    this.value = value;
  }
  update() {
  }
  toString() {
    return (this.left ? this.left.toString() + ' ' : '') + `(${this.key},${this.value})` + (this.right ? ' ' + this.right.toString() : '')
  }
}

class SplayTree {
  root;
  constructor(node) {
    this.root = node;
  }

  uptree(x, p, g) {
    if (!g) {
      // lazy update p, x
      if (p.left == x) {
        p.left = x.right;
        x.right = p;
      } else {
        p.right = x.left;
        x.left = p;
      }
      p.update(); x.update();
      return x;
    }
    // lazy update g, p, x
    if (g.left == p && p.left == x) {
      g.left = p.right;
      p.right = g;
      p.left = x.right;
      x.right = p;
    } else if (g.right == p && p.right == x) {
      g.right = p.left;
      p.left = g;
      p.right = x.left;
      x.left = p;
    } else if (g.left == p) {
      p.right = x.left;
      x.left = p;
      g.left = x.right;
      x.right = g;
    } else {
      p.left = x.right;
      x.right = p;
      g.right = x.left;
      x.left = g;
    }
    g.update(); p.update(); x.update();
    return x;
  }

  splay(trace) {
    var x = trace.pop();
    while (true) {
      var p = trace.pop();
      var g = trace.pop();
      if (!p) return this.root = x;
      if (!g || !trace.length) return this.root = this.uptree(x, p, g);
      if (trace[trace.length - 1].left == g) trace[trace.length - 1].left = x = this.uptree(x, p, g);
      else trace[trace.length - 1].right = x = this.uptree(x, p, g);
    }
  }

  insert(key, value) {
    if (!this.root) return this.root = new Node(key, value);
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      cur = key < cur.key ? cur.left : cur.right;
    }
    cur = trace[trace.length - 1];
    if (key < cur.key) trace.push(cur.left = new Node(key, value));
    else trace.push(cur.right = new Node(key, value));
    this.splay(trace);
  }

  join(tree) {
    if (!this.root) return this.root = tree.root;
    var trace = [this.root];
    var cur = this.root;
    while (cur.right) trace.push(cur = cur.right);
    this.splay(trace);
    this.root.right = tree.root;
    this.root.update();
  }

  remove(key) {
    if (!this.root) return;
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      if (cur.key == key) break;
      cur = key < cur.key ? cur.left : cur.right;
    }
    // if (trace[trace.length - 1].key != key) return;
    this.splay(trace);
    var node = this.root;
    var tree = new SplayTree(this.root.right);
    this.root = this.root.left;
    this.join(tree);
    return node;
  }

  load(nodes) {
    if (!nodes.length) return;
    this.root = nodes[0];
    let s = 1, k = 1;
    while (s < nodes.length) {
      let end = Math.min(s + k, nodes.length - 1);
      for (let i = end - 1; i >= s; i--) {
        nodes[i].right = nodes[i + 1];
        nodes[i].update();
      }
      this.root = nodes[s];
      this.root.left = nodes[s - k];
      this.root.update()
      s += ++k;
    }
  }

  print() {
    console.log(this.root ? this.root.toString() : undefined);
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new AVLTree()
  // let t = new SplayTree()
  d.forEach(v => t.insert(v.d, v.i))
  // t.print()
  while (!t.isEmpty()) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

var AVLTree = (function () {
  /**
   * Prints tree horizontally
   * @param  {Node}                       root
   * @param  {Function(node:Node):String} [printNode]
   * @return {String}
   */
  function print(root, printNode) {
    if (printNode === void 0) printNode = function (n) { return n.key; };

    var out = [];
    row(root, '', true, function (v) { return out.push(v); }, printNode);
    return out.join('');
  }

  /**
   * Is the tree balanced (none of the subtrees differ in height by more than 1)
   * @param  {Node}    root
   * @return {Boolean}
   */
  function isBalanced(root) {
    if (root === null) { return true; } // If node is empty then return true

    // Get the height of left and right sub trees
    var lh = height(root.left);
    var rh = height(root.right);

    if (Math.abs(lh - rh) <= 1 &&
      isBalanced(root.left) &&
      isBalanced(root.right)) { return true; }

    // If we reach here then tree is not height-balanced
    return false;
  }

  /**
   * The function Compute the 'height' of a tree.
   * Height is the number of nodes along the longest path
   * from the root node down to the farthest leaf node.
   *
   * @param  {Node} node
   * @return {Number}
   */
  function height(node) {
    return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
  }

  function loadRecursive(parent, keys, values, start, end) {
    var size = end - start;
    if (size > 0) {
      var middle = start + Math.floor(size / 2);
      var key = keys[middle];
      var data = values[middle];
      var node = { key: key, data: data, parent: parent };
      node.left = loadRecursive(node, keys, values, start, middle);
      node.right = loadRecursive(node, keys, values, middle + 1, end);
      return node;
    }
    return null;
  }

  function markBalance(node) {
    if (node === null) { return 0; }
    var lh = markBalance(node.left);
    var rh = markBalance(node.right);

    node.balanceFactor = lh - rh;
    return Math.max(lh, rh) + 1;
  }

  function sort(keys, values, left, right, compare) {
    if (left >= right) { return; }

    // eslint-disable-next-line no-bitwise
    var pivot = keys[(left + right) >> 1];
    var i = left - 1;
    var j = right + 1;

    // eslint-disable-next-line no-constant-condition
    while (true) {
      do { i++; } while (compare(keys[i], pivot) < 0);
      do { j--; } while (compare(keys[j], pivot) > 0);
      if (i >= j) { break; }

      var tmp = keys[i];
      keys[i] = keys[j];
      keys[j] = tmp;

      tmp = values[i];
      values[i] = values[j];
      values[j] = tmp;
    }

    sort(keys, values, left, j, compare);
    sort(keys, values, j + 1, right, compare);
  }

  // function createNode (parent, left, right, height, key, data) {
  //   return { parent, left, right, balanceFactor: height, key, data };
  // }

  /**
   * @typedef {{
   *   parent:        ?Node,
   *   left:          ?Node,
   *   right:         ?Node,
   *   balanceFactor: number,
   *   key:           Key,
   *   data:          Value
   * }} Node
   */

  /**
   * @typedef {*} Key
   */

  /**
   * @typedef {*} Value
   */

  /**
   * Default comparison function
   * @param {Key} a
   * @param {Key} b
   * @returns {number}
   */
  function DEFAULT_COMPARE(a, b) { return a > b ? 1 : a < b ? -1 : 0; }

  /**
   * Single left rotation
   * @param  {Node} node
   * @return {Node}
   */
  function rotateLeft(node) {
    var rightNode = node.right;
    node.right = rightNode.left;

    if (rightNode.left) { rightNode.left.parent = node; }

    rightNode.parent = node.parent;
    if (rightNode.parent) {
      if (rightNode.parent.left === node) {
        rightNode.parent.left = rightNode;
      } else {
        rightNode.parent.right = rightNode;
      }
    }

    node.parent = rightNode;
    rightNode.left = node;

    node.balanceFactor += 1;
    if (rightNode.balanceFactor < 0) {
      node.balanceFactor -= rightNode.balanceFactor;
    }

    rightNode.balanceFactor += 1;
    if (node.balanceFactor > 0) {
      rightNode.balanceFactor += node.balanceFactor;
    }
    return rightNode;
  }

  function rotateRight(node) {
    var leftNode = node.left;
    node.left = leftNode.right;
    if (node.left) { node.left.parent = node; }

    leftNode.parent = node.parent;
    if (leftNode.parent) {
      if (leftNode.parent.left === node) {
        leftNode.parent.left = leftNode;
      } else {
        leftNode.parent.right = leftNode;
      }
    }

    node.parent = leftNode;
    leftNode.right = node;

    node.balanceFactor -= 1;
    if (leftNode.balanceFactor > 0) {
      node.balanceFactor -= leftNode.balanceFactor;
    }

    leftNode.balanceFactor -= 1;
    if (node.balanceFactor < 0) {
      leftNode.balanceFactor += node.balanceFactor;
    }

    return leftNode;
  }

  // function leftBalance (node) {
  //   if (node.left.balanceFactor === -1) rotateLeft(node.left);
  //   return rotateRight(node);
  // }

  // function rightBalance (node) {
  //   if (node.right.balanceFactor === 1) rotateRight(node.right);
  //   return rotateLeft(node);
  // }

  var AVLTree = function AVLTree(comparator, noDuplicates) {
    if (noDuplicates === void 0) noDuplicates = false;

    this._comparator = comparator || DEFAULT_COMPARE;
    this._root = null;
    this._size = 0;
    this._noDuplicates = !!noDuplicates;
  };

  var prototypeAccessors = { size: { configurable: true } };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.destroy = function destroy() {
    return this.clear();
  };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.clear = function clear() {
    this._root = null;
    this._size = 0;
    return this;
  };

  /**
   * Number of nodes
   * @return {number}
   */
  prototypeAccessors.size.get = function () {
    return this._size;
  };

  /**
   * Whether the tree contains a node with the given key
   * @param{Key} key
   * @return {boolean} true/false
   */
  AVLTree.prototype.contains = function contains(key) {
    if (this._root) {
      var node = this._root;
      var comparator = this._comparator;
      while (node) {
        var cmp = comparator(key, node.key);
        if (cmp === 0) { return true; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    }
    return false;
  };

  /* eslint-disable class-methods-use-this */

  /**
   * Successor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.next = function next(node) {
    var successor = node;
    if (successor) {
      if (successor.right) {
        successor = successor.right;
        while (successor.left) { successor = successor.left; }
      } else {
        successor = node.parent;
        while (successor && successor.right === node) {
          node = successor; successor = successor.parent;
        }
      }
    }
    return successor;
  };

  /**
   * Predecessor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.prev = function prev(node) {
    var predecessor = node;
    if (predecessor) {
      if (predecessor.left) {
        predecessor = predecessor.left;
        while (predecessor.right) { predecessor = predecessor.right; }
      } else {
        predecessor = node.parent;
        while (predecessor && predecessor.left === node) {
          node = predecessor;
          predecessor = predecessor.parent;
        }
      }
    }
    return predecessor;
  };
  /* eslint-enable class-methods-use-this */

  /**
   * Callback for forEach
   * @callback forEachCallback
   * @param {Node} node
   * @param {number} index
   */

  /**
   * @param{forEachCallback} callback
   * @return {AVLTree}
   */
  AVLTree.prototype.forEach = function forEach(callback) {
    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      // Reach the left most Node of the current Node
      if (current) {
        // Place pointer to a tree node on the stack
        // before traversing the node's left subtree
        s.push(current);
        current = current.left;
      } else {
        // BackTrack from the empty subtree and visit the Node
        // at the top of the stack; however, if the stack is
        // empty you are done
        if (s.length > 0) {
          current = s.pop();
          callback(current, i++);

          // We have visited the node and its left
          // subtree. Now, it's right subtree's turn
          current = current.right;
        } else { done = true; }
      }
    }
    return this;
  };

  AVLTree.prototype.range = function range(low, high, fn, ctx) {
    var this$1 = this;

    var Q = [];
    var compare = this._comparator;
    var node = this._root, cmp;

    while (Q.length !== 0 || node) {
      if (node) {
        Q.push(node);
        node = node.left;
      } else {
        node = Q.pop();
        cmp = compare(node.key, high);
        if (cmp > 0) {
          break;
        } else if (compare(node.key, low) >= 0) {
          if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
        }
        node = node.right;
      }
    }
    return this;
  };

  /**
   * Returns all keys in order
   * @return {Array<Key>}
   */
  AVLTree.prototype.keys = function keys() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.key);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  AVLTree.prototype.values = function values() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.data);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  /**
   * Returns node at given index
   * @param{number} index
   * @return {?Node}
   */
  AVLTree.prototype.at = function at(index) {
    // removed after a consideration, more misleading than useful
    // index = index % this.size;
    // if (index < 0) index = this.size - index;

    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          if (i === index) { return current; }
          i++;
          current = current.right;
        } else { done = true; }
      }
    }
    return null;
  };

  /**
   * Returns node with the minimum key
   * @return {?Node}
   */
  AVLTree.prototype.minNode = function minNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node;
  };

  /**
   * Returns node with the max key
   * @return {?Node}
   */
  AVLTree.prototype.maxNode = function maxNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node;
  };

  /**
   * Min key
   * @return {?Key}
   */
  AVLTree.prototype.min = function min() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node.key;
  };

  /**
   * Max key
   * @return {?Key}
   */
  AVLTree.prototype.max = function max() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node.key;
  };

  /**
   * @return {boolean} true/false
   */
  AVLTree.prototype.isEmpty = function isEmpty() {
    return !this._root;
  };

  /**
   * Removes and returns the node with smallest key
   * @return {?Node}
   */
  AVLTree.prototype.pop = function pop() {
    var node = this._root, returnValue = null;
    if (node) {
      while (node.left) { node = node.left; }
      returnValue = { key: node.key, data: node.data };
      this.remove(node.key);
    }
    return returnValue;
  };

  /**
   * Find node by key
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.find = function find(key) {
    var root = this._root;
    // if (root === null)  return null;
    // if (key === root.key) return root;

    var subtree = root, cmp;
    var compare = this._comparator;
    while (subtree) {
      cmp = compare(key, subtree.key);
      if (cmp === 0) { return subtree; }
      else if (cmp < 0) { subtree = subtree.left; }
      else { subtree = subtree.right; }
    }

    return null;
  };

  /**
   * Insert a node into the tree
   * @param{Key} key
   * @param{Value} [data]
   * @return {?Node}
   */
  AVLTree.prototype.insert = function insert(key, data) {
    var this$1 = this;

    if (!this._root) {
      this._root = {
        parent: null, left: null, right: null, balanceFactor: 0,
        key: key, data: data
      };
      this._size++;
      return this._root;
    }

    var compare = this._comparator;
    var node = this._root;
    var parent = null;
    var cmp = 0;

    if (this._noDuplicates) {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp === 0) { return null; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    } else {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp <= 0) { node = node.left; } //return null;
        else { node = node.right; }
      }
    }

    var newNode = {
      left: null,
      right: null,
      balanceFactor: 0,
      parent: parent, key: key, data: data
    };
    var newRoot;
    if (cmp <= 0) { parent.left = newNode; }
    else { parent.right = newNode; }

    while (parent) {
      cmp = compare(parent.key, key);
      if (cmp < 0) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor === 0) { break; }
      else if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      }
      parent = parent.parent;
    }

    this._size++;
    return newNode;
  };

  /**
   * Removes the node from the tree. If not found, returns null.
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.remove = function remove(key) {
    var this$1 = this;

    if (!this._root) { return null; }

    var node = this._root;
    var compare = this._comparator;
    var cmp = 0;

    while (node) {
      cmp = compare(key, node.key);
      if (cmp === 0) { break; }
      else if (cmp < 0) { node = node.left; }
      else { node = node.right; }
    }
    if (!node) { return null; }

    var returnValue = node.key;
    var max, min;

    if (node.left) {
      max = node.left;

      while (max.left || max.right) {
        while (max.right) { max = max.right; }

        node.key = max.key;
        node.data = max.data;
        if (max.left) {
          node = max;
          max = max.left;
        }
      }

      node.key = max.key;
      node.data = max.data;
      node = max;
    }

    if (node.right) {
      min = node.right;

      while (min.left || min.right) {
        while (min.left) { min = min.left; }

        node.key = min.key;
        node.data = min.data;
        if (min.right) {
          node = min;
          min = min.right;
        }
      }

      node.key = min.key;
      node.data = min.data;
      node = min;
    }

    var parent = node.parent;
    var pp = node;
    var newRoot;

    while (parent) {
      if (parent.left === pp) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      }

      if (parent.balanceFactor === -1 || parent.balanceFactor === 1) { break; }

      pp = parent;
      parent = parent.parent;
    }

    if (node.parent) {
      if (node.parent.left === node) { node.parent.left = null; }
      else { node.parent.right = null; }
    }

    if (node === this._root) { this._root = null; }

    this._size--;
    return returnValue;
  };

  /**
   * Bulk-load items
   * @param{Array<Key>}keys
   * @param{Array<Value>}[values]
   * @return {AVLTree}
   */
  AVLTree.prototype.load = function load(keys, values, presort) {
    if (keys === void 0) keys = [];
    if (values === void 0) values = [];

    if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
    var size = keys.length;
    if (presort) { sort(keys, values, 0, size - 1, this._comparator); }
    this._root = loadRecursive(null, keys, values, 0, size);
    markBalance(this._root);
    this._size = size;
    return this;
  };

  /**
   * Returns true if the tree is balanced
   * @return {boolean}
   */
  AVLTree.prototype.isBalanced = function isBalanced$1() {
    return isBalanced(this._root);
  };

  /**
   * String representation of the tree - primitive horizontal print-out
   * @param{Function(Node):string} [printNode]
   * @return {string}
   */
  AVLTree.prototype.toString = function toString(printNode) {
    return print(this._root, printNode);
  };

  Object.defineProperties(AVLTree.prototype, prototypeAccessors);

  AVLTree.default = AVLTree;

  return AVLTree;

})();

class Node {
  left; right; key; value;
  constructor(key, value) {
    this.key = key;
    this.value = value;
  }
  update() {
  }
  toString() {
    return (this.left ? this.left.toString() + ' ' : '') + `(${this.key},${this.value})` + (this.right ? ' ' + this.right.toString() : '')
  }
}

class SplayTree {
  root;
  constructor(node) {
    this.root = node;
  }

  uptree(x, p, g) {
    if (!g) {
      // lazy update p, x
      if (p.left == x) {
        p.left = x.right;
        x.right = p;
      } else {
        p.right = x.left;
        x.left = p;
      }
      p.update(); x.update();
      return x;
    }
    // lazy update g, p, x
    if (g.left == p && p.left == x) {
      g.left = p.right;
      p.right = g;
      p.left = x.right;
      x.right = p;
    } else if (g.right == p && p.right == x) {
      g.right = p.left;
      p.left = g;
      p.right = x.left;
      x.left = p;
    } else if (g.left == p) {
      p.right = x.left;
      x.left = p;
      g.left = x.right;
      x.right = g;
    } else {
      p.left = x.right;
      x.right = p;
      g.right = x.left;
      x.left = g;
    }
    g.update(); p.update(); x.update();
    return x;
  }

  splay(trace) {
    var x = trace.pop();
    while (true) {
      var p = trace.pop();
      var g = trace.pop();
      if (!p) return this.root = x;
      if (!g || !trace.length) return this.root = this.uptree(x, p, g);
      if (trace[trace.length - 1].left == g) trace[trace.length - 1].left = x = this.uptree(x, p, g);
      else trace[trace.length - 1].right = x = this.uptree(x, p, g);
    }
  }

  insert(key, value) {
    if (!this.root) return this.root = new Node(key, value);
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      cur = key < cur.key ? cur.left : cur.right;
    }
    cur = trace[trace.length - 1];
    if (key < cur.key) trace.push(cur.left = new Node(key, value));
    else trace.push(cur.right = new Node(key, value));
    this.splay(trace);
  }

  join(tree) {
    if (!this.root) return this.root = tree.root;
    var trace = [this.root];
    var cur = this.root;
    while (cur.right) trace.push(cur = cur.right);
    this.splay(trace);
    this.root.right = tree.root;
    this.root.update();
  }

  remove(key) {
    if (!this.root) return;
    var trace = [];
    var cur = this.root;
    while (cur) {
      trace.push(cur);
      if (cur.key == key) break;
      cur = key < cur.key ? cur.left : cur.right;
    }
    // if (trace[trace.length - 1].key != key) return;
    this.splay(trace);
    var node = this.root;
    var tree = new SplayTree(this.root.right);
    this.root = this.root.left;
    this.join(tree);
    return node;
  }

  load(nodes) {
    if (!nodes.length) return;
    this.root = nodes[0];
    let s = 1, k = 1;
    while (s < nodes.length) {
      let end = Math.min(s + k, nodes.length - 1);
      for (let i = end - 1; i >= s; i--) {
        nodes[i].right = nodes[i + 1];
        nodes[i].update();
      }
      this.root = nodes[s];
      this.root.left = nodes[s - k];
      this.root.update()
      s += ++k;
    }
  }

  print() {
    console.log(this.root ? this.root.toString() : undefined);
  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, m, sx, sy, fx, fy] = $(6)
  let d = Arr(m, i => ({ i, x: $(), y: $(), e: [], d: 0, m: 0 }))
  d.sort((a, b) => a.x == b.x ? a.y - b.y : a.x - b.x).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].x - d[i].x })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].x - d[i].x })
  })
  d.sort((a, b) => a.y == b.y ? a.x - b.x : a.y - b.y).for(0, m - 2, (_, i, d) => {
    d[i].e.push({ v: d[i + 1], d: d[i + 1].y - d[i].y })
    d[i + 1].e.push({ v: d[i], d: d[i + 1].y - d[i].y })
  })
  d.sort((a, b) => a.i - b.i);
  d.forEach(v => v.d = min(abs(v.x - sx), abs(v.y - sy)))
  // log(d)
  let t = new AVLTree()
  d.forEach(v => t.insert(v.d, v.i))
  // t.print()
  while (!t.isEmpty()) {
    let v = d[t.pop().data];
    if (v.m) continue;
    v.m = 1;
    v.e.forEach(e => {
      if (v.d + e.d < d[e.v.i].d) {
        d[e.v.i].d = v.d + e.d;
        t.insert(v.d + e.d, e.v.i)
      }
    })
  }
  // log(d)
  let res = abs(fx - sx) + abs(fy - sy);
  d.forEach(v => res = min(res, v.d + abs(fx - v.x) + abs(fy - v.y)));
  log(res)
}

var AVLTree = (function () {
  /**
   * Prints tree horizontally
   * @param  {Node}                       root
   * @param  {Function(node:Node):String} [printNode]
   * @return {String}
   */
  function print(root, printNode) {
    if (printNode === void 0) printNode = function (n) { return n.key; };

    var out = [];
    row(root, '', true, function (v) { return out.push(v); }, printNode);
    return out.join('');
  }

  /**
   * Is the tree balanced (none of the subtrees differ in height by more than 1)
   * @param  {Node}    root
   * @return {Boolean}
   */
  function isBalanced(root) {
    if (root === null) { return true; } // If node is empty then return true

    // Get the height of left and right sub trees
    var lh = height(root.left);
    var rh = height(root.right);

    if (Math.abs(lh - rh) <= 1 &&
      isBalanced(root.left) &&
      isBalanced(root.right)) { return true; }

    // If we reach here then tree is not height-balanced
    return false;
  }

  /**
   * The function Compute the 'height' of a tree.
   * Height is the number of nodes along the longest path
   * from the root node down to the farthest leaf node.
   *
   * @param  {Node} node
   * @return {Number}
   */
  function height(node) {
    return node ? (1 + Math.max(height(node.left), height(node.right))) : 0;
  }

  function loadRecursive(parent, keys, values, start, end) {
    var size = end - start;
    if (size > 0) {
      var middle = start + Math.floor(size / 2);
      var key = keys[middle];
      var data = values[middle];
      var node = { key: key, data: data, parent: parent };
      node.left = loadRecursive(node, keys, values, start, middle);
      node.right = loadRecursive(node, keys, values, middle + 1, end);
      return node;
    }
    return null;
  }

  function markBalance(node) {
    if (node === null) { return 0; }
    var lh = markBalance(node.left);
    var rh = markBalance(node.right);

    node.balanceFactor = lh - rh;
    return Math.max(lh, rh) + 1;
  }

  function sort(keys, values, left, right, compare) {
    if (left >= right) { return; }

    // eslint-disable-next-line no-bitwise
    var pivot = keys[(left + right) >> 1];
    var i = left - 1;
    var j = right + 1;

    // eslint-disable-next-line no-constant-condition
    while (true) {
      do { i++; } while (compare(keys[i], pivot) < 0);
      do { j--; } while (compare(keys[j], pivot) > 0);
      if (i >= j) { break; }

      var tmp = keys[i];
      keys[i] = keys[j];
      keys[j] = tmp;

      tmp = values[i];
      values[i] = values[j];
      values[j] = tmp;
    }

    sort(keys, values, left, j, compare);
    sort(keys, values, j + 1, right, compare);
  }

  // function createNode (parent, left, right, height, key, data) {
  //   return { parent, left, right, balanceFactor: height, key, data };
  // }

  /**
   * @typedef {{
   *   parent:        ?Node,
   *   left:          ?Node,
   *   right:         ?Node,
   *   balanceFactor: number,
   *   key:           Key,
   *   data:          Value
   * }} Node
   */

  /**
   * @typedef {*} Key
   */

  /**
   * @typedef {*} Value
   */

  /**
   * Default comparison function
   * @param {Key} a
   * @param {Key} b
   * @returns {number}
   */
  function DEFAULT_COMPARE(a, b) { return a > b ? 1 : a < b ? -1 : 0; }

  /**
   * Single left rotation
   * @param  {Node} node
   * @return {Node}
   */
  function rotateLeft(node) {
    var rightNode = node.right;
    node.right = rightNode.left;

    if (rightNode.left) { rightNode.left.parent = node; }

    rightNode.parent = node.parent;
    if (rightNode.parent) {
      if (rightNode.parent.left === node) {
        rightNode.parent.left = rightNode;
      } else {
        rightNode.parent.right = rightNode;
      }
    }

    node.parent = rightNode;
    rightNode.left = node;

    node.balanceFactor += 1;
    if (rightNode.balanceFactor < 0) {
      node.balanceFactor -= rightNode.balanceFactor;
    }

    rightNode.balanceFactor += 1;
    if (node.balanceFactor > 0) {
      rightNode.balanceFactor += node.balanceFactor;
    }
    return rightNode;
  }

  function rotateRight(node) {
    var leftNode = node.left;
    node.left = leftNode.right;
    if (node.left) { node.left.parent = node; }

    leftNode.parent = node.parent;
    if (leftNode.parent) {
      if (leftNode.parent.left === node) {
        leftNode.parent.left = leftNode;
      } else {
        leftNode.parent.right = leftNode;
      }
    }

    node.parent = leftNode;
    leftNode.right = node;

    node.balanceFactor -= 1;
    if (leftNode.balanceFactor > 0) {
      node.balanceFactor -= leftNode.balanceFactor;
    }

    leftNode.balanceFactor -= 1;
    if (node.balanceFactor < 0) {
      leftNode.balanceFactor += node.balanceFactor;
    }

    return leftNode;
  }

  // function leftBalance (node) {
  //   if (node.left.balanceFactor === -1) rotateLeft(node.left);
  //   return rotateRight(node);
  // }

  // function rightBalance (node) {
  //   if (node.right.balanceFactor === 1) rotateRight(node.right);
  //   return rotateLeft(node);
  // }

  var AVLTree = function AVLTree(comparator, noDuplicates) {
    if (noDuplicates === void 0) noDuplicates = false;

    this._comparator = comparator || DEFAULT_COMPARE;
    this._root = null;
    this._size = 0;
    this._noDuplicates = !!noDuplicates;
  };

  var prototypeAccessors = { size: { configurable: true } };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.destroy = function destroy() {
    return this.clear();
  };

  /**
   * Clear the tree
   * @return {AVLTree}
   */
  AVLTree.prototype.clear = function clear() {
    this._root = null;
    this._size = 0;
    return this;
  };

  /**
   * Number of nodes
   * @return {number}
   */
  prototypeAccessors.size.get = function () {
    return this._size;
  };

  /**
   * Whether the tree contains a node with the given key
   * @param{Key} key
   * @return {boolean} true/false
   */
  AVLTree.prototype.contains = function contains(key) {
    if (this._root) {
      var node = this._root;
      var comparator = this._comparator;
      while (node) {
        var cmp = comparator(key, node.key);
        if (cmp === 0) { return true; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    }
    return false;
  };

  /* eslint-disable class-methods-use-this */

  /**
   * Successor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.next = function next(node) {
    var successor = node;
    if (successor) {
      if (successor.right) {
        successor = successor.right;
        while (successor.left) { successor = successor.left; }
      } else {
        successor = node.parent;
        while (successor && successor.right === node) {
          node = successor; successor = successor.parent;
        }
      }
    }
    return successor;
  };

  /**
   * Predecessor node
   * @param{Node} node
   * @return {?Node}
   */
  AVLTree.prototype.prev = function prev(node) {
    var predecessor = node;
    if (predecessor) {
      if (predecessor.left) {
        predecessor = predecessor.left;
        while (predecessor.right) { predecessor = predecessor.right; }
      } else {
        predecessor = node.parent;
        while (predecessor && predecessor.left === node) {
          node = predecessor;
          predecessor = predecessor.parent;
        }
      }
    }
    return predecessor;
  };
  /* eslint-enable class-methods-use-this */

  /**
   * Callback for forEach
   * @callback forEachCallback
   * @param {Node} node
   * @param {number} index
   */

  /**
   * @param{forEachCallback} callback
   * @return {AVLTree}
   */
  AVLTree.prototype.forEach = function forEach(callback) {
    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      // Reach the left most Node of the current Node
      if (current) {
        // Place pointer to a tree node on the stack
        // before traversing the node's left subtree
        s.push(current);
        current = current.left;
      } else {
        // BackTrack from the empty subtree and visit the Node
        // at the top of the stack; however, if the stack is
        // empty you are done
        if (s.length > 0) {
          current = s.pop();
          callback(current, i++);

          // We have visited the node and its left
          // subtree. Now, it's right subtree's turn
          current = current.right;
        } else { done = true; }
      }
    }
    return this;
  };

  AVLTree.prototype.range = function range(low, high, fn, ctx) {
    var this$1 = this;

    var Q = [];
    var compare = this._comparator;
    var node = this._root, cmp;

    while (Q.length !== 0 || node) {
      if (node) {
        Q.push(node);
        node = node.left;
      } else {
        node = Q.pop();
        cmp = compare(node.key, high);
        if (cmp > 0) {
          break;
        } else if (compare(node.key, low) >= 0) {
          if (fn.call(ctx, node)) { return this$1; } // stop if smth is returned
        }
        node = node.right;
      }
    }
    return this;
  };

  /**
   * Returns all keys in order
   * @return {Array<Key>}
   */
  AVLTree.prototype.keys = function keys() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.key);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  AVLTree.prototype.values = function values() {
    var current = this._root;
    var s = [], r = [], done = false;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          r.push(current.data);
          current = current.right;
        } else { done = true; }
      }
    }
    return r;
  };

  /**
   * Returns node at given index
   * @param{number} index
   * @return {?Node}
   */
  AVLTree.prototype.at = function at(index) {
    // removed after a consideration, more misleading than useful
    // index = index % this.size;
    // if (index < 0) index = this.size - index;

    var current = this._root;
    var s = [], done = false, i = 0;

    while (!done) {
      if (current) {
        s.push(current);
        current = current.left;
      } else {
        if (s.length > 0) {
          current = s.pop();
          if (i === index) { return current; }
          i++;
          current = current.right;
        } else { done = true; }
      }
    }
    return null;
  };

  /**
   * Returns node with the minimum key
   * @return {?Node}
   */
  AVLTree.prototype.minNode = function minNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node;
  };

  /**
   * Returns node with the max key
   * @return {?Node}
   */
  AVLTree.prototype.maxNode = function maxNode() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node;
  };

  /**
   * Min key
   * @return {?Key}
   */
  AVLTree.prototype.min = function min() {
    var node = this._root;
    if (!node) { return null; }
    while (node.left) { node = node.left; }
    return node.key;
  };

  /**
   * Max key
   * @return {?Key}
   */
  AVLTree.prototype.max = function max() {
    var node = this._root;
    if (!node) { return null; }
    while (node.right) { node = node.right; }
    return node.key;
  };

  /**
   * @return {boolean} true/false
   */
  AVLTree.prototype.isEmpty = function isEmpty() {
    return !this._root;
  };

  /**
   * Removes and returns the node with smallest key
   * @return {?Node}
   */
  AVLTree.prototype.pop = function pop() {
    var node = this._root, returnValue = null;
    if (node) {
      while (node.left) { node = node.left; }
      returnValue = { key: node.key, data: node.data };
      this.remove(node.key);
    }
    return returnValue;
  };

  /**
   * Find node by key
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.find = function find(key) {
    var root = this._root;
    // if (root === null)  return null;
    // if (key === root.key) return root;

    var subtree = root, cmp;
    var compare = this._comparator;
    while (subtree) {
      cmp = compare(key, subtree.key);
      if (cmp === 0) { return subtree; }
      else if (cmp < 0) { subtree = subtree.left; }
      else { subtree = subtree.right; }
    }

    return null;
  };

  /**
   * Insert a node into the tree
   * @param{Key} key
   * @param{Value} [data]
   * @return {?Node}
   */
  AVLTree.prototype.insert = function insert(key, data) {
    var this$1 = this;

    if (!this._root) {
      this._root = {
        parent: null, left: null, right: null, balanceFactor: 0,
        key: key, data: data
      };
      this._size++;
      return this._root;
    }

    var compare = this._comparator;
    var node = this._root;
    var parent = null;
    var cmp = 0;

    if (this._noDuplicates) {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp === 0) { return null; }
        else if (cmp < 0) { node = node.left; }
        else { node = node.right; }
      }
    } else {
      while (node) {
        cmp = compare(key, node.key);
        parent = node;
        if (cmp <= 0) { node = node.left; } //return null;
        else { node = node.right; }
      }
    }

    var newNode = {
      left: null,
      right: null,
      balanceFactor: 0,
      parent: parent, key: key, data: data
    };
    var newRoot;
    if (cmp <= 0) { parent.left = newNode; }
    else { parent.right = newNode; }

    while (parent) {
      cmp = compare(parent.key, key);
      if (cmp < 0) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor === 0) { break; }
      else if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        break;
      }
      parent = parent.parent;
    }

    this._size++;
    return newNode;
  };

  /**
   * Removes the node from the tree. If not found, returns null.
   * @param{Key} key
   * @return {?Node}
   */
  AVLTree.prototype.remove = function remove(key) {
    var this$1 = this;

    if (!this._root) { return null; }

    var node = this._root;
    var compare = this._comparator;
    var cmp = 0;

    while (node) {
      cmp = compare(key, node.key);
      if (cmp === 0) { break; }
      else if (cmp < 0) { node = node.left; }
      else { node = node.right; }
    }
    if (!node) { return null; }

    var returnValue = node.key;
    var max, min;

    if (node.left) {
      max = node.left;

      while (max.left || max.right) {
        while (max.right) { max = max.right; }

        node.key = max.key;
        node.data = max.data;
        if (max.left) {
          node = max;
          max = max.left;
        }
      }

      node.key = max.key;
      node.data = max.data;
      node = max;
    }

    if (node.right) {
      min = node.right;

      while (min.left || min.right) {
        while (min.left) { min = min.left; }

        node.key = min.key;
        node.data = min.data;
        if (min.right) {
          node = min;
          min = min.right;
        }
      }

      node.key = min.key;
      node.data = min.data;
      node = min;
    }

    var parent = node.parent;
    var pp = node;
    var newRoot;

    while (parent) {
      if (parent.left === pp) { parent.balanceFactor -= 1; }
      else { parent.balanceFactor += 1; }

      if (parent.balanceFactor < -1) {
        // inlined
        //var newRoot = rightBalance(parent);
        if (parent.right.balanceFactor === 1) { rotateRight(parent.right); }
        newRoot = rotateLeft(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      } else if (parent.balanceFactor > 1) {
        // inlined
        // var newRoot = leftBalance(parent);
        if (parent.left.balanceFactor === -1) { rotateLeft(parent.left); }
        newRoot = rotateRight(parent);

        if (parent === this$1._root) { this$1._root = newRoot; }
        parent = newRoot;
      }

      if (parent.balanceFactor === -1 || parent.balanceFactor === 1) { break; }

      pp = parent;
      parent = parent.parent;
    }

    if (node.parent) {
      if (node.parent.left === node) { node.parent.left = null; }
      else { node.parent.right = null; }
    }

    if (node === this._root) { this._root = null; }

    this._size--;
    return returnValue;
  };

  /**
   * Bulk-load items
   * @param{Array<Key>}keys
   * @param{Array<Value>}[values]
   * @return {AVLTree}
   */
  AVLTree.prototype.load = function load(keys, values, presort) {
    if (keys === void 0) keys = [];
    if (values === void 0) values = [];

    if (this._size !== 0) { throw new Error('bulk-load: tree is not empty'); }
    var size = keys.length;
    if (presort) { sort(keys, values, 0, size - 1, this._comparator); }
    this._root = loadRecursive(null, keys, values, 0, size);
    markBalance(this._root);
    this._size = size;
    return this;
  };

  /**
   * Returns true if the tree is balanced
   * @return {boolean}
   */
  AVLTree.prototype.isBalanced = function isBalanced$1() {
    return isBalanced(this._root);
  };

  /**
   * String representation of the tree - primitive horizontal print-out
   * @param{Function(Node):string} [printNode]
   * @return {string}
   */
  AVLTree.prototype.toString = function toString(printNode) {
    return print(this._root, printNode);
  };

  Object.defineProperties(AVLTree.prototype, prototypeAccessors);

  AVLTree.default = AVLTree;

  return AVLTree;

})();