#include <bits/stdc++.h>
using namespace std;
int a[100010];
int main() {
  int n, k;
  cin >> n >> k;
  int p = 0, js = 0;
  for (int t = 0; t < k; t++) {
    int m;
    scanf("%d", &m);
    js += m - 1;
    for (int i = 0; i < m; i++) {
      scanf("%d", a + i);
    }
    for (int i = 0; i < m; i++) {
      if (i == 0 and a[0] == 1) {
        p = 1;
        while (a[i] == p and i < m) {
          i++, p++;
        }
      }
    }
  }
  p--;
  p--;
  js += n - 1;
  js -= p * 2;
  cout << js << endl;
  return 0;
}
