#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5;
int main() {
  vector<int> goh_nakhor[maxn];
  int n, k, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int num, tmp;
    cin >> num >> tmp;
    if (tmp != 1) ans += num - 1;
    for (int i = 0; i < num - 1; i++) {
      int val;
      cin >> val;
      goh_nakhor[tmp].push_back(val);
    }
  }
  int cnt = 0;
  for (int i = 0; i < goh_nakhor[1].size(); i++) {
    if (goh_nakhor[1][i] == i + 2) cnt++;
  }
  cout << ans + (goh_nakhor[1].size() - cnt - 1) + n - cnt << '\n';
  return 0;
}
