#include <bits/stdc++.h>
using namespace std;
vector<int> v[100000];
int main() {
  int n, k;
  cin >> n >> k;
  int v1;
  int m;
  for (int i = 0; i < k; i++) {
    cin >> m;
    int temp;
    for (int j = 0; j < m; j++) {
      cin >> temp;
      if (temp == 1) v1 = i;
      v[i].push_back(temp);
    }
  }
  int time = 0;
  int cont = 0;
  int j = 0;
  int sz = v[v1].size();
  while (j < sz) {
    if (v[v1][j] == j + 1)
      cont++;
    else
      break;
    j++;
  }
  for (int i = 0; i < k; i++) {
    if (i != v1) {
      time += v[i].size() - 1;
    }
  }
  time += (sz - cont);
  time += (n - cont);
  cout << time;
  return 0;
}
