#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int arr[m];
  vector<vector<int>> v;
  for (int i = 0; i < m; i++) {
    cin >> arr[i];
    vector<int> v1(arr[i]);
    for (int j = 0; j < arr[i]; j++) {
      cin >> v1[j];
    }
    v.push_back(v1);
  }
  int part = m - 1, t = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 1; j < arr[i]; j++) {
      if (v[i][0] == 1 && v[i][j] == j + 1) {
        ;
      } else {
        t++;
        part++;
      }
    }
  }
  cout << part + t;
  return 0;
}
