#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const long long int Inf = 1LL << 62;
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy8[] = {1, 0, -1, 1, -1, 1, 0, -1};
long long int ar[Max], br[Max];
int main() {
  long long int n, m, k, q, t, cnt = 0, sum = 0, mx = -Inf, mn = Inf;
  scanf("%lld %lld", &n, &m);
  for (int i = 1; i <= m; i++) {
    long long int x;
    scanf("%lld", &x);
    ar[x]++;
    long long int flg = 0;
    for (int j = 1; j <= n; j++) {
      if (ar[j] == 0) {
        flg = 1;
        break;
      }
    }
    if (flg) continue;
    cnt++;
    for (int j = 1; j <= n; j++) ar[j]--;
  }
  cout << (cnt) << endl;
  return 0;
}
