#include <bits/stdc++.h>
using namespace std;
map<int, int> seen;
vector<int> v;
int main() {
  int n, m, i, x, len;
  long long int mini = 1000000000;
  cin >> n >> m;
  int arr[m + 1];
  for (i = 0; i < m; i++) {
    cin >> x;
    if (seen[x] == 0) {
      v.push_back(x);
    }
    seen[x]++;
  }
  sort(v.begin(), v.end());
  len = v.size();
  if (len != n) {
    cout << 0 << endl;
    goto end;
  }
  for (i = 0; i < v.size(); i++) {
    if (mini > seen[v[i]]) {
      mini = seen[v[i]];
    }
  }
  cout << mini << endl;
end:
  return 0;
}
