#include <bits/stdc++.h>
using namespace std;
int n, k, m;
int buf[100000];
int res, cnt;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; ++i) {
    scanf("%d", &m);
    for (int j = 0; j < m; ++j) scanf("%d", &buf[j]);
    if (buf[0] == 1) {
      int j;
      for (j = 1; j < m && buf[j] == j + 1; ++j)
        ;
      res += m - j;
      cnt = j;
    } else {
      res += m - 1;
    }
  }
  res += n - cnt;
  printf("%d", res);
  return 0;
}
