#include <bits/stdc++.h>
using namespace std;
int square[((int)1001)], q = 0;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, p, ans = 0;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p;
    if (!square[p]) {
      q++;
      square[p] = 1;
      if (q == n) {
        ans++;
        for (int j = 1; j <= n; j++) {
          square[j]--;
          if (!square[j]) q--;
        }
      }
    } else
      square[p]++;
  }
  cout << ans << '\n';
  return 0;
}
