#include <bits/stdc++.h>
using namespace std;
int a[100010];
int f[100010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int ans = 0;
  while (k--) {
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
    for (int i = 1; i < m; i++) f[a[i]] = a[i + 1];
    ans += m - 1;
  }
  int st = 1;
  while (st < n && f[st] == st + 1) st++;
  ans -= st - 1;
  ans += n - st;
  printf("%d\n", ans);
  return 0;
}
