#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
int n,m,a[1001];
typedef pair <int,int> P;
typedef pair<P,int> PP;

int solve(){
  PP t[1001];
  t[0]=PP(P((m/a[0])*a[0],a[0]),0);
  for(int i=1;i<n;i++){
    sort(t,t+i);
    P ima=t[0].f;
    int nx=((ima.f-1)/a[i])*a[i]+a[i];
    if(ima.f==nx&&ima.s>a[i]) nx+=a[i];
    if(m<nx)nx-=a[i];
    t[i]=PP(P(nx,a[i]),i);
  }
  sort(t,t+n);
  if(t[0].f==t[1].f)return n;
  return t[0].s+1;
 }

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++) cin>>a[i];
    cout<<solve()<<endl;      
  }
  return 0;
}