#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} a[100005];
vector<pair<int, int> > b[100005];
vector<int> d;
bool cmp(node A, node B) {
  if (A.x == B.x) return A.y < B.y;
  return A.x < B.x;
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d%d", &a[i].x, &a[i].y);
  sort(a, a + M, cmp);
  int c = 0;
  for (int i = 0; i < M; i++) {
    if (i == 0 || a[i - 1].x != a[i].x) {
      if (1 <= a[i].y - 1) {
        b[c].push_back(make_pair(1, a[i].y - 1));
      }
      d.push_back(a[i].x);
    } else if (a[i - 1].x == a[i].x) {
      if (a[i - 1].y + 1 <= a[i].y - 1)
        b[c].push_back(make_pair(a[i - 1].y + 1, a[i].y - 1));
    }
    if (i == M - 1 || a[i].x != a[i + 1].x) {
      if (a[i].y + 1 <= N) b[c].push_back(make_pair(a[i].y + 1, N));
      c++;
    }
  }
  if (a[0].x == 1) b[0].erase(b[0].begin() + 1, b[0].end());
  for (int i = 0; i < c; i++) {
    int n1 = b[i].size();
    int n2 = b[i - 1].size();
    if (i > 0) {
      if (d[i] != d[i - 1] + 1) {
        for (int j = 0; j < n1; j++)
          b[i][j].first = max(b[i - 1][0].first, b[i][j].first);
      } else {
        int p = 0;
        for (int j = 0; j < n1; j++) {
          while (p < n2 && b[i - 1][p].second < b[i][j].first) p++;
          if (p == n2)
            b[i][j].first = N + 1;
          else
            b[i][j].first = max(b[i - 1][p].first, b[i][j].first);
        }
      }
      for (int j = 0; j < b[i].size();) {
        if (b[i][j].first > b[i][j].second)
          b[i].erase(b[i].begin() + j);
        else
          j++;
      }
    }
    if (b[i].empty()) {
      printf("-1\n");
      return 0;
    }
  }
  int r = b[c - 1].size();
  if (d[c - 1] != N || (r && b[c - 1][r - 1].second == N)) {
    printf("%d\n", 2 * N - 2);
  } else
    printf("-1\n");
  return 0;
}
