#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int i, n, t, k, j, m, s1;
  cin >> n >> k;
  s1 = n - k + n - 1;
  for (i = 0; i < k; i++) {
    cin >> m;
    for (j = 0; j < m; j++) {
      cin >> a[j];
    }
    if (a[0] == 1) {
      j = 1;
      while (a[j] == a[j - 1] + 1 && j < m) {
        j++;
      }
      j--;
      j *= 2;
      s1 = s1 - j;
    }
  }
  cout << s1 << endl;
  return 0;
}
