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