#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, tmp_in;
  vector<int> a[100000];
  int n_chains, n_ops = 0, p, a_sz;
  cin >> n >> k;
  for (int i = 0; i < k; ++i) {
    cin >> m;
    a[i].reserve(m);
    for (int j = 0; j < m; ++j) {
      cin >> tmp_in;
      a[i].push_back(tmp_in);
    }
  }
  n_chains = k;
  for (int i = 0; i < k; ++i) {
    a_sz = a[i].size();
    if (a[i][0] == 1 && a_sz != 1) {
      p = 1;
      while (a[i][p] == a[i][p - 1] + 1 && p < a_sz) {
        p++;
      }
      if (p != a_sz) {
        n_ops += a_sz - p;
        n_chains += a_sz - p;
      }
    } else {
      n_chains += a_sz - 1;
      n_ops += a_sz - 1;
    }
  }
  n_ops += n_chains - 1;
  cout << n_ops << endl;
  return 0;
}
