#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  long long ash = k;
  long long j = 0;
  while (k--) {
    long long m;
    cin >> m;
    vector<long long> arr(m);
    for (auto &x : arr) {
      cin >> x;
    }
    if (arr[0] == 1) {
      for (long long i = 0; i < m - 1; ++i) {
        if (arr[i + 1] != arr[i] + 1) {
          j += m - i - 1;
          break;
        }
      }
      j++;
    } else {
      j += m;
    }
  }
  cout << 2 * j - ash - 1;
  return;
}
int32_t main() {
  c_p_c();
  solve();
  return 0;
}
