#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k;
vector<int> a[N];
int one;
int ans;
int main() {
  int i, j;
  int m, x;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= k; i++) {
    scanf("%d", &m);
    for (j = 1; j <= m; j++) {
      scanf("%d", &x);
      a[i].push_back(x);
      if (x == 1) {
        one = i;
      }
    }
  }
  int cont = 1;
  for (i = 1; i < a[one].size(); i++) {
    if (a[one][i] != a[one][i - 1] + 1) {
      break;
    }
    cont++;
  }
  ans = n - 2 * cont + 1;
  for (i = 1; i <= k; i++) {
    ans += a[i].size() - 1;
  }
  printf("%d\n", ans);
  return 0;
}
