#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, x;
  cin >> n >> k;
  int res = 2 * n - k - 1;
  for (int i = 0; i < k; ++i) {
    cin >> m;
    for (int j = 0; j < m; ++j) {
      cin >> x;
      if (j > 0 && x == j + 1) res -= 2;
    }
  }
  cout << res << endl;
  return 0;
}
