#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int main() {
  int n, k, m, t, i, c[N];
  scanf("%d%d", &n, &k);
  int ans = 0;
  while (k--) {
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%d", &c[i]);
    }
    if (c[0] == 1) {
      for (i = 0; i < m; i++) {
        if (c[i] != i + 1) break;
      }
      ans += m - i;
      t = i;
    } else if (c[0] != 1)
      ans += m - 1;
  }
  ans += n - t;
  printf("%d\n", ans);
  return 0;
}
