#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
const int N = 100005, MOD = 1e9 + 7;
int n, k, m[N], ptr[N], cnt[N];
vector<int> a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> k;
  int ind = 0, ans = 0;
  for (int i = 0; i < k; ++i) {
    cin >> m[i];
    for (int j = 0, x; j < m[i]; ++j) {
      cin >> x;
      a[i].push_back(x);
    }
    if (a[i][0] == 1) {
      int j = 0;
      while (j + 1 < m[i] && a[i][j + 1] - a[i][j] == 1) {
        ++j;
      }
      ans = (n - m[i] - k + 1) + (m[i] - j - 1) + (n - j - 1);
    }
  }
  cout << ans << '\n';
  return 0;
}
