#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int a[n];
  int num;
  int i, j;
  int index = -2;
  if (k == 1)
    printf("0\n");
  else {
    for (i = 0; i < k; i++) {
      scanf("%d", &num);
      for (j = 0; j < num; j++) scanf("%d", &a[j]);
      a[num] = -5;
      if (a[0] == 1) {
        for (j = 1; j < n; j++) {
          if (a[j] != j + 1) {
            index = j;
            break;
          }
        }
      }
    }
    printf("%d\n", (n - index) * 2 - k + 1);
  }
  return 0;
}
