#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  s << "{ ";
  for (int i = 0; i < t.size(); ++i) s << t[i] << ' ';
  s << "}";
  return s;
}
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << '(' << t.first << ", " << t.second << ')';
}
struct debugger {
  template <typename T>
  debugger &operator,(const T &v) {
    cerr << v << ' ';
    return *this;
  }
} DBG;
template <class T>
inline bool checkBit(T n, T i) {
  return n & ((T)1 << i);
}
template <class T>
inline T setBit(T n, T i) {
  return (n | ((T)1 << i));
}
template <class T>
inline T resetBit(T n, T i) {
  return (n & (~((T)1 << i)));
}
int n;
int a[100002], head[100002], chain[100002];
int main() {
  int k, m;
  scanf("%d%d", &n, &k);
  int cnt = 0;
  while (k--) {
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) scanf("%d", &a[i]);
    cnt += m - 1;
    if (a[0] == 1)
      for (int i = 1; i < m && a[i] == i + 1; ++i) cnt -= 2;
  }
  cnt += n - 1;
  printf("%d\n", cnt);
  return 0;
}
