#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
int n, k;
int a[maxn];
int main() {
  scanf("%d%d", &n, &k);
  int ans = 0;
  int l = 0;
  while (k--) {
    bool flag = false;
    int m;
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) {
      scanf("%d", &a[i]);
      if (a[1] == 1) flag = true;
    }
    if (flag) {
      l = 1;
      for (int i = 2; i <= m; i++) {
        if (a[i] == (a[i - 1] + 1))
          l++;
        else
          break;
      }
      ans += m - l;
    } else
      ans += m - 1;
  }
  ans += n - l;
  printf("%d\n", ans);
  return 0;
}
