#include <bits/stdc++.h>
int main() {
  int x, m, n, k, ans, len = 0, cur = 1;
  scanf("%d %d", &n, &k);
  ans = 2 * n - k - 1;
  for (int i = 0; i < k; ++i) {
    scanf("%d", &m);
    for (int j = 0; j < m; ++j) {
      scanf("%d", &x);
      if (x == cur) {
        ++cur;
        ++len;
      }
    }
    cur = 1;
  }
  ans -= 2 * (len - 1);
  printf("%d", ans);
}
