#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  while (b) {
    long long int temp = b;
    b = a % b;
    a = temp;
  }
  return a;
}
int main() {
  int n, k;
  cin >> n >> k;
  int res2 = 0;
  int res = 0;
  for (int i = 0; i < k; i++) {
    int tmp;
    cin >> tmp;
    bool fnd = false;
    for (int j = 1; j <= tmp; j++) {
      int temp;
      cin >> temp;
      if (temp == 1) {
        fnd = true;
      }
      if (fnd and temp == j) res += 1;
    }
    res2 += (tmp - 1);
  }
  cout << (res2 - res + 1) + (n - res) << endl;
  return 0;
}
