#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, m, aux, sol = 0, i = 1;
  cin >> n >> k;
  while (k--) {
    cin >> m;
    sol += m - 1;
    while (m > 0) {
      cin >> aux;
      m--;
      if (aux == 1) {
        while (aux == i and m > 0) {
          cin >> aux;
          i++;
          m--;
        }
        if (m <= 0 and aux == i) i++;
      }
    }
  }
  i -= 2;
  sol += (n - 1);
  sol -= 2 * i;
  cout << sol << endl;
}
