#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int seconds = 0;
  int n;
  int chain;
  cin >> n >> chain;
  int nest = n - 1;
  for (int i = 0; i < chain; i++) {
    int doll;
    cin >> doll;
    int skip = 1;
    for (int j = 0; j < doll; j++) {
      int dolls;
      cin >> dolls;
      if (j == 0) {
        continue;
      }
      if (dolls == j + 1) {
        skip++;
        nest--;
      }
    }
    seconds += (doll - skip);
  }
  cout << seconds + nest << endl;
  return 0;
}
