#include <bits/stdc++.h>
using namespace std;
int c, d, i, n, m, k = 0, j, x = 1, f, l, ans;
int main() {
  cin >> n >> m;
  int a, b[n];
  for (i = 0; i < m; i++) {
    cin >> a;
    c = c + a;
    for (j = 0; j < a; j++) {
      cin >> b[k];
      if (b[k] == 1) {
        f = k;
        l = c;
      }
      k++;
    }
  }
  for (i = f; i < l; i++) {
    if (b[i] == x) {
      ans++;
      x++;
    }
  }
  ans--;
  cout << c - m + (n - 1) - (2 * ans);
}
