#include <bits/stdc++.h>
using namespace std;
int p, x;
string s;
int good[100001];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    int m;
    cin >> m;
    x += m - 1;
    int as = 1, ls = -1;
    for (int j = 1; j <= m; j++) {
      int y;
      cin >> y;
      if (ls + 1 == y) good[ls] = 1;
      ls = y;
    }
  }
  for (int i = 1; i < n; i++) {
    if (good[i])
      p++;
    else
      break;
  }
  cout << x + n - p - p - 1;
}
