#include <bits/stdc++.h>
using namespace std;
const double eps = 1.0e-11;
const double pi = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    int k, curr = 0;
    cin >> k;
    vector<int> d(k);
    for (long long j = 0; j < k; j++) cin >> d[j];
    while (curr < k && curr + 1 == d[curr]) ++curr;
    if (curr) {
      cout << n - m + n - 1 - 2 * (curr - 1) << endl;
      return 0;
    }
  }
  return 0;
}
