#include <bits/stdc++.h>
using namespace std;
int n, k, m, a[100010], b, tmp = 0, ans = 0;
void count_time() {
  int res = 0;
  a[m + 1] = 10000000;
  for (int i = 1; i <= m; ++i)
    if (a[i] == a[i + 1] - 1)
      ++res;
    else
      break;
  ans = n - res;
  tmp += m - res - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    cin >> m;
    for (int j = 1; j <= m; ++j) cin >> a[j];
    if (a[1] == 1)
      count_time();
    else
      tmp += m - 1;
  }
  cout << ans - 1 + tmp;
}
