#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long k;
  cin >> n >> k;
  vector<vector<long long> > a;
  a.resize(k);
  long long m;
  long long res = 2 * n - k + 1;
  for (long long i = 0; i < k; i++) {
    cin >> m;
    a[i].resize(m);
    for (long long j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == j + 1) res -= 2;
    }
  }
  cout << res << endl;
}
