#include <bits/stdc++.h>
int main() {
  int n, k, m, vl, vc;
  bool flag;
  while (scanf("%d%d", &n, &k) == 2) {
    int ans = 0;
    while (k--) {
      scanf("%d%d", &m, &vl);
      flag = (vl == 1);
      while (--m) {
        scanf("%d", &vc);
        if (flag && vc - vl == 1)
          n--;
        else
          ans++;
        vl = vc;
      }
    }
    ans += n - 1;
    printf("%d\n", ans);
  }
  return 0;
}
