#include <bits/stdc++.h>
using namespace std;
int n, br, k, num, ans;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d", &br);
    for (int j = 1; j <= br; j++) {
      scanf("%d", &num);
      if (num != j) ans++;
    }
  }
  printf("%d\n", 2 * ans - k + 1);
}
