#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
vector<int> v[maxn];
int main() {
  int n, k, m, x;
  cin >> n >> k;
  int tmp = n - k + n - 1;
  for (int i = 1; i <= k; i++) {
    cin >> m;
    for (int j = 1; j <= m; j++) cin >> x, v[i].push_back(x);
  }
  for (int i = 1; i <= k; i++) {
    if (v[i][0] == 1) {
      for (int j = 1; j < v[i].size(); j++) {
        if (v[i][j] != v[i][j - 1] + 1) {
          tmp = tmp - j - j + 2;
          break;
        } else if (j == v[i].size() - 1) {
          tmp = tmp - j - j;
        }
      }
    }
  }
  cout << tmp;
  return 0;
}
