#include <bits/stdc++.h>
using namespace std;
int c[1005];
int n, m;
map<int, int> f;
int check() {
  for (int i = 1; i <= n; i++) {
    if (f[i] == 0) return 0;
  }
  return 1;
}
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> c[i];
  }
  int ans = 0;
  for (int i = 1; i <= m; i++) {
    f[c[i]]++;
    if (check() == 0) {
      continue;
    }
    for (int j = 1; j <= n; j++) {
      f[j]--;
    }
    ans++;
  }
  cout << ans << endl;
}
