#include <bits/stdc++.h>
#pragma GCC optimize("03")
using namespace std;
int n, m, c[1010], x, cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int j = 1; j <= m; j++) {
    cin >> x;
    c[x]++;
    int cur = 0;
    for (int i = 1; i <= n; i++)
      if (c[i] > 0) cur++;
    if (cur == n) {
      cnt++;
      for (int i = 1; i <= n; i++) c[i]--;
    }
  }
  cout << cnt;
  return 0;
}
