#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  ;
  long int n, k, i, j, len;
  vector<long int> temp;
  temp.reserve(100010);
  cin >> n >> k;
  long int no, l, r;
  long int cnt = 0;
  long int flag = 0;
  long int last = -1;
  long int chain_len = 0;
  long int broke = 0;
  while (k--) {
    cin >> len;
    flag = 0;
    broke = 0;
    for (i = 0; i < len; i++) {
      cin >> no;
      if (no == 1) {
        flag = 1;
        last = no;
        chain_len++;
        continue;
      }
      if (flag) {
        if (no == last + 1) {
          last = no;
          chain_len++;
        } else {
          broke++;
        }
      }
    }
    if (len == 1) broke = 0;
    if (broke)
      cnt += broke;
    else if (!flag)
      cnt += len - 1;
  }
  cnt += (n - chain_len);
  cout << cnt << endl;
  return 0;
}
