#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100500;
long long elem;
int main() {
  long long n, k;
  cin >> n >> k;
  long long x = 0;
  for (int i = 0; i < k; i++) {
    long long m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      cin >> elem;
      if (elem == j + 1) x++;
    }
  }
  cout << 2 * (n - x + 1) - k - 1;
  return 0;
}
