#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int main() {
  int n, k;
  int templen;
  int time = 0;
  int temp;
  vector<int> vec;
  cin >> n >> k;
  time = n - 1;
  for (int i = 0; i < k; ++i) {
    cin >> templen;
    vec.clear();
    for (int j = 0; j < templen; ++j) {
      cin >> temp;
      vec.push_back(temp);
    }
    if (templen > 1) {
      bool flag = false;
      if (vec[0] == 1) flag = true;
      for (int j = 1; j < templen; ++j) {
        if (flag && vec[j] == (vec[j - 1] + 1)) {
          --time;
        } else {
          flag = false;
          ++time;
        }
      }
    }
  }
  cout << time << endl;
  return 0;
}
