#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<int> mat[100005];
int main() {
  scanf("%d %d", &n, &k);
  for (int it = 1; it <= k; it++) {
    int mi;
    scanf("%d", &mi);
    for (int j = 0; j < mi; j++) {
      int x;
      scanf("%d", &x);
      mat[it].push_back(x);
    }
  }
  int ret = 0;
  int cmp = 0;
  for (int i = 1; i <= k; i++) {
    cmp++;
    for (int j = 0; j < mat[i].size() - 1; j++) {
      if (mat[i][j] + 1 != mat[i][j + 1]) {
        ret++;
        cmp++;
      }
    }
  }
  ret = ret + cmp - 1;
  cout << ret << endl;
  return 0;
}
