#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int one;
  for (int i = 0; i < (k); ++i) {
    int(m);
    scanf("%d", &m);
    vector<int> me;
    for (int i = 0; i < (m); ++i) {
      int(x);
      scanf("%d", &x);
      me.push_back(x);
    }
    if (me[0] == 1) {
      int j;
      for (j = 1; j < ((int)(me).size()) && me[j] == me[j - 1] + 1; j++)
        ;
      one = j;
    }
  }
  printf("%d\n", n - one - (k - 1) + (n - one));
  return 0;
}
