#include <bits/stdc++.h>
using namespace std;
char fi;
const int INF = 2000000007;
const double eps = 1e-12;
const double DINF = 1e30;
template <class A>
ostream& operator<<(ostream& out, pair<A, A> ab) {
  out << '(' << ab.first << ", " << ab.second << ')';
  return out;
}
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  for (int i = 0; i < int(v.size()); ++i)
    if (i != v.size() - 1) out << v[i] << ' ';
  out << v[v.size() - 1] << '\n';
  return out;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(6);
  int n, k;
  cin >> n >> k;
  int m, seg = 0;
  while (cin >> m) {
    int x;
    cin >> x;
    if (x == 1) {
      for (int i = 0; i < m - 1; ++i) {
        cin >> x;
        if (x - i == 2) ++seg;
      }
    } else
      for (int i = 0; i < m - 1; ++i) cin >> x;
  }
  cout << (n - seg - k) + (n - seg - 1) << '\n';
}
