#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, k, counter = 0, counter1 = 0, ans = 0;
  cin >> n >> k;
  int A[n + 1];
  for (i = 0; i < k; i++) {
    counter1 = 0;
    int t, j;
    cin >> t;
    for (j = 0; j < t; j++) cin >> A[j];
    A[j] = -1;
    for (j = 1; j <= t; j++)
      if (A[j] != A[j - 1] + 1) {
        counter1 = counter1 + 1;
        counter = counter + 1;
      }
    counter1 = counter1 - 1;
    ans = ans + counter1;
  }
  ans = ans + counter - 1;
  cout << ans << "\n";
  return 0;
}
