#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
  for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
    out << v[i] << " ";
  out << "\n";
  return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N> > &v) {
  for (size_t i = 0; i < v.size(); ++i)
    out << "(" << v[i].first << ", " << v[i].second << ") ";
  out << "\n";
  return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T> > &v) {
  for (size_t i = 0; i < v.size(); ++i) {
    for (size_t j = 0; j < v[i].size(); ++j) {
      out << v[i][j] << " ";
    }
    out << "\n";
  }
  return out;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<vector<int> > assemblage(k, vector<int>());
  vector<pair<int, int> > positions(n + 1);
  int m;
  for (int i = 0; i < k; ++i) {
    cin >> m;
    int a;
    for (int j = 0; j < m; ++j) {
      cin >> a;
      assemblage[i].push_back(a);
      positions[a] = {i, j};
    }
  }
  int min_time = 0;
  int next_matryoshka = 2;
  int pieces = k;
  for (int i = 0; i < k; ++i) {
    if (assemblage[i][0] != 1) {
      pieces += assemblage[i].size() - 1;
      min_time += assemblage[i].size() - 1;
    } else {
      for (int j = 0; j < (int)assemblage[i].size() - 1; ++j) {
        if (assemblage[i][j + 1] != assemblage[i][j] + 1) {
          pieces += assemblage[i].size() - j - 1;
          min_time += assemblage[i].size() - j - 1;
          break;
        }
      }
    }
  }
  cout << min_time + pieces - 1 << "\n";
  return 0;
}
