#include <bits/stdc++.h>
using namespace std;
int d2x[] = {1, -1, 0, 0, 1, -1, 1, -1};
int d2y[] = {0, 0, 1, -1, 1, -1, -1, 1};
int d3x[] = {1, -1, 0, 0, 0, 0};
int d3y[] = {0, 0, 1, -1, 0, 0};
int d3z[] = {0, 0, 0, 0, 1, -1};
struct edge {
  int from, to, w;
  edge(int from, int to, int w) : from(from), to(to), w(w) {}
  bool operator<(const edge& e) const { return w > e.w; }
};
const double EPS = (1e-9);
int n, k, m, last, cnt = 0;
vector<vector<int> > lists;
bool flag;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> k;
  lists.resize(k);
  for (int i = 0; i < k; i++) {
    cin >> m;
    lists[i].resize(m);
    flag = false;
    for (int j = 0; j < m; j++) {
      cin >> lists[i][j];
      if (lists[i][j] == 1) {
        last = 1;
        flag = true;
      } else if (flag && lists[i][j] == last + 1)
        ++last;
      else if (j)
        ++cnt;
    }
  }
  cout << cnt + n - last;
  return 0;
}
