#include <bits/stdc++.h>
using namespace std;
int const maxn = 100006;
int nxt[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n = 0;
  int k = 0;
  cin >> n >> k;
  int a = 0;
  int ai = 100000000;
  int flag = 0;
  for (int i = 0; i < k; ++i) {
    int cur = 0;
    cin >> cur;
    for (int j = 0; j < cur; ++j) {
      int tmp = 0;
      cin >> tmp;
      if (tmp == a + 1 && i <= ai) {
        ai = i;
        ++a;
      }
      if (ai == i && a != tmp && flag == 0) flag = 1;
    }
  }
  int ans = flag + (n - a - k + 1 - flag);
  ans += n - a;
  cout << ans << endl;
  return 0;
}
