#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int N, K;
int main() {
  int x, y, num;
  while (scanf("%d%d", &N, &K) != EOF) {
    int cnt = 0, ans = 0;
    for (int i = 0; i < K; i++) {
      scanf("%d", &num);
      int p = 1;
      for (int j = 0; j < num; j++) {
        scanf("%d", &x);
        if (j && x != y + 1) p++;
        y = x;
      }
      cnt += p;
      ans += p - 1;
    }
    ans += cnt - 1;
    printf("%d\n", ans);
  }
  return 0;
}
