#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, i, x, ans = 0, m, serie = 0, id = 0;
  cin >> n >> k;
  for (i = 1; i <= k; i++) {
    cin >> m;
    int ok = 1;
    for (int j = 1; j <= m; j++) {
      cin >> x;
      if (x == 1) id = i;
      if (x != j) ok = 0;
      if (ok == 1) serie++;
    }
    if (i == id)
      ans = ans + m - serie;
    else
      ans = ans + m - 1;
  }
  ans = ans + n - serie;
  cout << ans;
  return 0;
}
