#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n = 0, k = 0;
  cin >> n >> k;
  vector<vector<int> > a(k);
  for (int i = 0; i < k; i++) {
    int m = 0;
    cin >> m;
    a[i].resize(m);
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  int ans = n - 1 + n - k;
  int i = 0;
  while (a[i][0] != 1) i++;
  int j = 1;
  while (j < a[i].size() && a[i][j] == j + 1) {
    ans -= 2;
    j++;
  }
  cout << ans;
  return 0;
}
