#include <bits/stdc++.h>
using namespace std;
int n, k, ans, groups, m, temp, last;
int main(void) {
  cin >> n >> k;
  ans = groups = 0;
  for (int x = 1; x <= k; x++) {
    cin >> m >> last;
    groups++;
    for (int i = 2; i <= m; i++) {
      cin >> temp;
      if (temp - last > 1) {
        ans++;
        groups++;
      }
      last = temp;
    }
  }
  ans += (groups - 1);
  cout << ans << endl;
}
