#include <bits/stdc++.h>
using namespace std;
int in() {
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    ch = getchar();
  }
  int res = 0;
  while (ch >= '0' && ch <= '9') {
    res = 10 * res + ch - '0';
    ch = getchar();
  }
  return res;
}
int main() {
  int n = in(), k = in();
  int m;
  int t;
  int num;
  int temp = 1;
  int res = 0;
  for (int i = 0; i < k; i++) {
    m = in();
    t = in();
    if (1 == t) {
      bool flag = true;
      for (int i = 0; i < m - 1; i++) {
        num = in();
        if (num == ++t && flag) {
          temp++;
          continue;
        } else {
          flag = false;
          res++;
        }
      }
    } else {
      for (int i = 0; i < m - 1; i++) {
        num = in();
        res++;
      }
    }
  }
  cout << n - temp + res << endl;
  return 0;
}
