#include <bits/stdc++.h>
using namespace std;
int a[1010];
int main() {
  int n, m;
  cin >> n >> m;
  int tmp;
  int ans = 0;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= m; i++) {
    cin >> tmp;
    a[tmp]++;
    int b = 1;
    for (int i = 1; i <= n; i++)
      if (!a[i]) b = 0;
    if (b) {
      ans++;
      for (int i = 1; i <= m; i++) a[i]--;
    }
  }
  cout << ans << endl;
  return 0;
}
