#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  map<int, int> mp;
  int mx[n + 10];
  memset(mx, 0, sizeof mx);
  for (int i = 0; i < k; i++) {
    int a;
    int b;
    scanf("%d", &b);
    for (int j = 0; j < b; j++) {
      scanf("%d", &a);
      adj[i].push_back(a);
      mx[i] = max(mx[i], a);
      mp[a] = i;
    }
  }
  long long cnt = 0;
  for (int i = 1; i < n; i++) {
    if (mp[i] == mp[i + 1]) continue;
    int a = mp[i];
    int b = mp[i + 1];
    if (mx[a] == i) {
      mp[i] = b;
      cnt++;
    } else {
      cnt += 2;
      mp[i] = b;
    }
  }
  cout << cnt << endl;
  return 0;
}
