#include <bits/stdc++.h>
using namespace std;
int a[1005];
int main() {
  int n, m, t, count = 0, score = 0;
  bool judge;
  scanf("%d%d", &n, &m);
  memset(a, 0, sizeof(a));
  for (int i = 0; i < m; i++) {
    scanf("%d", &t);
    a[t - 1]++;
    judge = true;
    for (int k = 0; k < n; k++) {
      if (a[k] == count) {
        judge = false;
        break;
      }
    }
    if (judge) {
      score++;
      count++;
    }
  }
  printf("%d\n", score);
  return 0;
}
