#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j, m, flag, breaks = 0, chains = 0, a, b, cnt = 0;
  scanf("%lld", &n);
  scanf("%lld", &k);
  for (i = 0; i < k; i++) {
    scanf("%lld", &m);
    scanf("%lld", &a);
    cnt = 1;
    flag = 1;
    for (j = 1; j < m; j++) {
      scanf("%lld", &b);
      if (a != b - 1 || flag == 0) {
        breaks++;
        cnt++;
        flag = 0;
      }
      a = b;
    }
    chains += cnt;
  }
  cout << breaks + chains - 1;
  return 0;
}
