#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  long long part = 0;
  long long ans = 0;
  for (int i = 0; i < k; i++) {
    int x;
    scanf("%d", &x);
    for (int j = 0; j < x; j++) scanf("%d", &a[j]);
    if (x == 1) {
      part++;
      continue;
    } else {
      int ok = 0;
      for (int j = 0; j < x; j++) {
        if (a[j] == 1)
          ok = 1;
        else if (ok == 1 && a[j] == a[j - 1] + 1)
          continue;
        else {
          ok = 0;
          if (j != 0) {
            part++;
            ans++;
          }
        }
      }
      part++;
    }
  }
  ans += part - 1;
  printf("%lld", ans);
  return 0;
}
