#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c;
  int f = 1, ret = 0;
  while ((c = getchar()) > '9' || c < '0')
    ;
  if (c == '-')
    f = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + c - '0';
  return ret * f;
}
int n, k, m, a = 0, ans;
int main() {
  n = read();
  k = read();
  ans = (n - 1) * 2 - k + 1;
  for (int i = 1; i <= k; i++) {
    m = read();
    a = read();
    if (a == 1) {
      for (int j = 2; j <= m; j++) {
        a = read();
        if (a != j)
          break;
        else
          ans -= 2;
      }
      printf("%d\n", ans);
      return 0;
    }
    for (int j = 2; j <= m; j++) a = read();
  }
  return 0;
}
