#include <bits/stdc++.h>
using namespace std;
int N, K;
int main() {
  int x, y, num;
  while (scanf("%d%d", &N, &K) != EOF) {
    long long cnt = 0, ans = 0;
    for (int i = 0; i < K; i++) {
      scanf("%d", &num);
      int p = 1;
      bool flag = 0;
      for (int j = 0; j < num; j++) {
        scanf("%d", &x);
        if (x == 1) flag = 1;
        if (j && x == y + 1) p++;
        y = x;
      }
      if (flag) cnt = p;
    }
    ans = (N - cnt) * 2 - (K - 1);
    cout << ans << endl;
  }
  return 0;
}
