#include <bits/stdc++.h>
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int con = 0;
  int ans = 0;
  for (int i = 0; i != k; i++) {
    int m;
    scanf("%d", &m);
    int j0;
    scanf("%d", &j0);
    if (j0 != 1) {
      ans += m - 1;
      for (int j = 1; j != m; j++) {
        scanf("%*d");
      }
    } else {
      for (int j = 1; j != m; j++) {
        int now;
        scanf("%d", &now);
        if (now == j + 1) con++;
      }
      ans += m - 1 - con;
    }
  }
  ans += n - 1 - con;
  printf("%d\n", ans);
  return 0;
}
