#include <bits/stdc++.h>
using namespace std;
void machayenge() {
  long long int n, k;
  cin >> n >> k;
  long long int ans = n - 1;
  long long int tmp = 0;
  long long int c = 0;
  for (long long int i = 0; i < k; ++i) {
    long long int re = 0;
    cin >> re;
    c += re - 1;
    long long int arrr[re];
    long long int flag = 0;
    for (long long int i = 0; i < re; ++i) {
      cin >> arrr[i];
      if (arrr[0] == 1) flag = 1;
    }
    if (flag == 1) {
      long long int j = 1;
      while (j < re && arrr[j] - arrr[j - 1] == 1) {
        tmp++;
        j++;
      }
    }
  }
  ans += c - 2 * (tmp);
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  machayenge();
  return 0;
}
