#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0), cout.precision(15);
  int n, k;
  cin >> n >> k;
  int count = 0, time = 0;
  for (int i = 0; i < k; i++) {
    int x;
    cin >> x;
    int arr[100005];
    for (int i = 0; i < x; i++) cin >> arr[i];
    for (int i = 0; i < x - 1; i++) {
      if (arr[i + 1] - arr[i] != 1) {
        count++;
        time++;
      }
    }
    count++;
  }
  cout << time + count - 1;
  ;
}
