#include <bits/stdc++.h>
using namespace std;
int a[1005], n;
bool check() {
  for (int i = 0; i < n; i++)
    if (a[i] == 0) return false;
  return true;
}
void reduce() {
  for (int i = 0; i < n; i++) a[i]--;
}
int main() {
  int m, x, points = 0;
  cin >> n >> m;
  memset(a, 0, sizeof a);
  for (int i = 0; i < m; i++) {
    cin >> x;
    a[x - 1]++;
    if (check()) {
      points++;
      reduce();
    }
  }
  cout << points;
  return 0;
}
