#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, k, pi = n, ans = 0, l;
  cin >> n >> k;
  vector<int> te(n + 1);
  for (l = 0; l < k; l++) {
    pi++;
    int m;
    cin >> m;
    vector<int> v(m);
    for (j = 0; j < m; j++) cin >> v[j];
    te[v[m - 1]] = v[m - 1];
    for (i = m - 2; i >= 0; i--) {
      if (v[i] != v[i + 1] - 1) {
        te[v[i]] = v[i];
        ans++;
      } else
        te[v[i]] = te[v[i + 1]];
    }
  }
  for (i = te[1] + 1; i <= n; i++) {
    ans = (ans + 2 * (te[i] - i) + 1);
    i = te[i];
  }
  cout << ans << "\n";
  return 0;
}
