#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int> > v[100005];
vector<long long int> all;
long long int bs(long long int x);
int main() {
  long long int n, k;
  cin >> n >> k;
  for (long long int i = 0; i < k; i++) {
    long long int cl;
    cin >> cl;
    for (long long int j = 0; j < cl; j++) {
      long long int x;
      cin >> x;
      all.push_back(x);
      v[i].push_back(make_pair(x, -1));
    }
  }
  sort(all.begin(), all.end());
  for (long long int i = 0; i < k; i++) {
    for (long long int j = 0; j < v[i].size(); j++) {
      long long int pos = bs(v[i][j].first);
      v[i][j].second = pos;
    }
  }
  long long int ans = 0;
  for (long long int i = 0; i < k; i++) {
    if (v[i][0].second != 0)
      ans += (v[i].size() + v[i].size() - 1);
    else {
      long long int j = 0;
      while (j < v[i].size() && v[i][j].second == j) j++;
      ans = ans + (1 + v[i].size() - j + v[i].size() - j);
    }
  }
  cout << ans - 1;
  return 0;
}
long long int bs(long long int x) {
  long long int lo = 0, hi = all.size() - 1;
  while (lo <= hi) {
    long long int mid = (lo + hi) / 2;
    if (all[mid] == x)
      return mid;
    else if (all[mid] > x)
      hi = mid - 1;
    else
      lo = mid + 1;
  }
}
