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