#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) return b;
  if (a > b) {
    return gcd(a % b, b);
  } else
    return gcd(b % a, a);
}
int main() {
  int t, i, j, q, n;
  int k;
  cin >> k >> q;
  int ans = 0;
  int a[100008];
  bool fl = true;
  for (i = 0; i < q; i++) {
    cin >> n;
    cin >> a[0];
    for (j = 1; j < n; j++) {
      cin >> a[j];
      if (a[j] - a[j - 1] == 1) ans++;
    }
  }
  cout << (q - 1) + 2 * (k - q - ans) << endl;
}
