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