#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];
  int ct = 0;
  bool fl = true;
  for (i = 0; i < q; i++) {
    cin >> n;
    cin >> a[0];
    if (a[0] == 1) {
      j = 1;
      while (j < n) {
        cin >> a[j];
        j++;
        if (a[j - 1] - a[j - 2] == 1)
          ans++;
        else
          break;
      }
      while (j < n) {
        cin >> a[j];
        j++;
      }
    } else {
      for (j = 1; j < n; j++) cin >> a[j];
    }
  }
  cout << (q - 1) + 2 * (k - q - ans) << endl;
}
