#include <bits/stdc++.h>
using namespace std;
int a[111111];
int main() {
  int i, j, n, k, m, ans = 0, t = 0;
  cin >> n >> k;
  for (i = 1; i <= k; i++) {
    cin >> m;
    for (j = 1; j <= m; j++) {
      cin >> a[j];
    }
    for (j = 1; j < m; j++) {
      if (a[j + 1] - a[j] > 1) break;
    }
    ans += m - j;
    t += j - 1;
  }
  ans = ans + n - t - 1;
  cout << ans;
}
