#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, l, cnt = 0, maxcnt = 0;
  cin >> n >> m;
  vector<int> temp;
  vector<vector<int> > list;
  vector<int>::iterator viter;
  vector<vector<int> >::iterator vviter;
  for (i = 0; i < m; i++) {
    cin >> j;
    temp.clear();
    for (k = 0; k < j; k++) {
      cin >> l;
      temp.push_back(l);
    }
    list.push_back(temp);
  }
  for (vviter = list.begin(); vviter != list.end(); vviter++) {
    cnt = 0;
    for (viter = vviter->begin(); viter != vviter->end(); viter++) {
      if (*viter == cnt + 1) {
        cnt++;
      }
    }
    if (cnt > maxcnt) maxcnt = cnt;
  }
  cout << (n - list.size()) + (n - 1) - 2 * (maxcnt - 1) << endl;
  return 0;
}
