#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int a[maxn], n, m, k, len, ans;
int main() {
  ans = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) scanf("%d", &a[j]);
    if (a[1] == 1) {
      len = 1;
      for (int j = 2; j <= k; j++)
        if (a[j] == j) len++;
      ans = ans + (k - len);
    } else
      ans = ans + (k - 1);
  }
  cout << ans + (n - len) << endl;
}
