#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, ans = 0, cnt = 0, temp;
  cin >> n >> k;
  while (k--) {
    int n1, a, b, flag = 0;
    cin >> n1;
    cnt = 0;
    for (int i = 0; i < n1; i++) {
      cin >> a;
      if (i == 0 && a == 1) {
        flag = 1;
        b = a;
      } else {
        if (flag == 1) {
          if (a - b == 1) {
            cnt++;
            b = a;
          }
        }
      }
    }
    if (flag == 1) temp = cnt;
    ans += n1 - cnt - 1;
  }
  ans += n - temp - 1;
  cout << ans;
  return 0;
}
