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