#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, k, m;
int a[100010];
int main() {
  while (scanf("%d%d", &n, &k) != EOF) {
    int ok = 1;
    for (int i = 0; i < k; ++i) {
      bool tag = false;
      scanf("%d", &m);
      for (int j = 0; j < m; ++j) {
        scanf("%d", a + j);
        if (j == 0 && a[j] == 1) tag = true;
        if (tag && j > 0) {
          if (a[j] - a[j - 1] == 1)
            ++ok;
          else
            tag = false;
        }
      }
    }
    printf("%d\n", (n - k - ok + 1) + (n - ok));
  }
  return 0;
}
