#include <bits/stdc++.h>
using namespace std;
int N, K, M, a[100005], sep, s;
int main() {
  scanf("%d %d", &N, &K);
  s = K;
  for (int m = 0; m < (K); m++) {
    scanf("%d", &M);
    for (int i = 0; i < (M); i++) scanf("%d", &a[i]);
    for (int i = 0; i < (M - 1); i++)
      if (a[i] != a[i + 1] - 1) {
        s++, sep++;
      }
  }
  printf("%d\n", s + sep - 1);
  return 0;
}
