#include <bits/stdc++.h>
using namespace std;
const int mn = 1e5 + 5;
int n, k, w[mn], w2[mn];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  int ans = 0, ans2 = 0;
  for (int x = 0, y; x < k; ++x) {
    cin >> y;
    ans += y - 1;
    for (int z = 0; z < y; ++z) cin >> w2[z];
    if (w2[0] == 1) {
      ans2 = 1;
      for (ans2 = 1; ans2 < y; ++ans2)
        if (w2[ans2] != w2[ans2 - 1] + 1) break;
      ans -= (ans2 - 1);
    }
  }
  cout << ans + n - ans2 << "\n";
  return 0;
}
