#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<vector<int> > mt;
  for (int i = 0; i < k; i++) {
    vector<int> v;
    mt.push_back(v);
    int nk;
    cin >> nk;
    for (int j = 0; j < nk; j++) {
      int el;
      cin >> el;
      mt[i].push_back(el);
    }
  }
  int count = 0;
  for (int i = 0; i < k; i++) {
    if (mt[i][0] == 1) {
      for (int j = 1; j < mt[i].size(); j++) {
        if (mt[i][j] == mt[i][j - 1] + 1)
          count++;
        else
          break;
      }
    }
  }
  n = n - count;
  int ans = n - k + n - 1;
  cout << ans << "\n";
  return 0;
}
