#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> blocks(n);
  vector<int> levels(m);
  for (int i = 0; i < m; i++) {
    int block;
    cin >> block;
    blocks[block - 1] += 1;
    levels[blocks[block - 1] - 1] += 1;
  }
  int ans = 0;
  for (auto& it : levels) {
    if (it == n) ans++;
  }
  cout << ans << endl;
  return 0;
}
