#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, y, x[301] = {0}, out = -1;
  cin >> p >> n;
  for (int i = 1; i <= n; i++) {
    cin >> y;
    x[y % p]++;
    if (x[y % p] == 2 && out == -1) out = i;
  }
  cout << out << endl;
}
