#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double eps = 1e-9;
const long long maxn = 1e5 + 1;
const long long inf = 1e15;
const long long minf = -inf;
bool solve() {
  long long n, m, ans;
  cin >> n >> m;
  ans = 2 * n - m + 1;
  vector<vector<long long>> v(m);
  for (long long i = 0, tmp; i < m; ++i) {
    cin >> tmp;
    for (long long j = 0, x; j < tmp; ++j) {
      cin >> x;
      v[i].push_back(x);
    }
  }
  for (long long i = 0; i < m; ++i) {
    for (long long j = 0; j < v[i].size(); ++j) {
      if (v[i][j] == j + 1) ans -= 2;
    }
  }
  cout << ans << "\n";
  return true;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    if (solve()) {
    } else {
    }
  }
  return 0;
}
