#include <bits/stdc++.h>
using namespace std;
const int N = 1002;
int n, m, ans;
int c[N];
int bin[N];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int x;
    scanf("%d", &x);
    bin[x]++;
    int mn = 1000000;
    for (int j = 1; j <= n; j++) {
      mn = min(mn, bin[j]);
    }
    if (mn) {
      ans++;
      for (int j = 1; j <= n; j++) bin[j]--;
    }
  }
  cout << ans << endl;
}
