#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
int n, k, a[N];
int work() {
  int ret = 0, cnt = 0;
  for (int i = 1; i <= k; i++) {
    int m;
    scanf("%d", &m);
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[j]);
    }
    if (a[0] != 1) {
      ret += m - 1;
      cnt += m;
    } else {
      int x = m;
      for (int j = 0; j < m - 1; j++)
        if (a[j] + 1 != a[j + 1]) {
          x = j + 1;
          break;
        }
      if (x == m) {
        cnt++;
      } else {
        ret += m - x;
        cnt += m - x + 1;
      }
    }
  }
  ret += cnt - 1;
  return ret;
}
int main() {
  scanf("%d%d", &n, &k);
  printf("%d\n", work());
  return 0;
}
