#include <bits/stdc++.h>
int main() {
  int n, k, m, arr[100000 + 7];
  while (scanf("%d%d", &n, &k) == 2) {
    int ans = 0;
    while (k--) {
      scanf("%d", &m);
      for (int i = 0; i < m; i++) scanf("%d", arr + i);
      if (arr[0] == 1) {
        for (int i = 1; i < m; i++) {
          if (arr[i] - arr[i - 1] > 1) {
            ans += m - i;
            break;
          }
          n--;
        }
      } else
        ans += m - 1;
    }
    ans += n - 1;
    printf("%d\n", ans);
  }
  return 0;
}
