#include <bits/stdc++.h>
using namespace std;
long long arr[100010];
long long arr1[100010];
int main() {
  long long n, k;
  cin >> n >> k;
  long long p = 0;
  long long sum1 = 0;
  for (long long i = 0; i < k; i++) {
    long long m, sum = 0;
    cin >> m;
    long long flag = 0;
    for (long long j = 0; j < m; j++) {
      cin >> arr1[j];
      if (j != 0 && flag == 0) {
        if (arr1[j] == arr1[j - 1] + 1)
          sum++;
        else
          flag = 1;
      }
    }
    long long ans = m - sum;
    arr[p++] = ans;
    sum1 += (m - (sum + 1));
  }
  long long x2 = 0;
  for (long long i = 0; i < k; i++) x2 += arr[i];
  cout << x2 + sum1 - 1 << endl;
}
