#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1061109567;
const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int a[100005];
int main() {
  int n, m, k;
  cin >> n >> m;
  int cnt = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      scanf("%d", &a[j]);
    }
    if (a[1] == 1) {
      for (int j = 2; j <= k; j++) {
        if (a[j] == a[j - 1] + 1)
          cnt++;
        else
          break;
      }
    }
  }
  int ans = 2 * (n - cnt) - (m - 1);
  cout << ans << endl;
  return 0;
}
