#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int N,M;
struct state{
  int t,l,id;
  bool operator<(const state& st) const {
    if( t == st.t ) return l>st.l;
    return t > st.t;
  }
  bool operator>(const state& st) const {
    if( t == st.t ) return l<st.l;
    return t < st.t;
  }
  state(int t,int l,int id) : t(t),l(l),id(id){}
  state(){}
};
int main(){
  while( cin >> N >>M &&(N|M) ) {
    priority_queue<state> sp;
    for(int i=0;i<N;i++){
      int a; cin >> a;
      int tmp = a;
      state gp;
      if( sp.empty() ) gp = state(M,10000,-1);      
      else gp = sp.top();
      while( state(a,tmp,(i+1)) > gp && a < M ) a+=tmp;
      if( a > M ) a -= tmp;
      sp.push( state( a, tmp, i+1 ) );
    }
    state res = sp.top(); sp.pop();
    bool f = false;
    while( !sp.empty() ){
      state p = sp.top(); sp.pop();
      if( res.t == p.t && res.l == p.l ) f = true;
      // cout << res.t << " "<< res.l <<" " << res.id << endl;
      //cout << p.t << " "<< p.l <<" " << p.id << endl;
    }
    if( f ) cout << N << endl;
    else cout << res.id << endl;
  }
}