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