#include<bits/stdc++.h>
using namespace std;
const int MAX_N=1030;
int n,k,nxt[MAX_N],top;
bool vis[MAX_N];
vector<int> a[MAX_N];
int query(int x){
	printf("? %d\n",x);
	fflush(stdout);
	static char s[15];
	scanf("%s",s);
	return s[0]=='Y';
}
void clr(){
	puts("R");
	fflush(stdout);
}
vector<int> rev(vector<int> a){
	reverse(a.begin(),a.end());
	return a;
}
void solve(vector<int> a){
	int cnt=k;
	for(auto x:a){
		vis[x]|=query(x);
		--cnt;
	}
	while(cnt--) query(a.back());
}
void dfs(int x){
	if(x>top) return;
	solve(a[x]);
	dfs(nxt[x]);
	nxt[x]++;
}
int main(){
	scanf("%d%d",&n,&k),top=n/k;
	for(int i=1;i<=top;++i){
		clr();
		for(int j=(i-1)*k+1;j<=i*k;++j)
			if(!query(j)) a[i].push_back(j);
	}
	for(int i=1;i<=top;++i) nxt[i]=i+1;
	while(nxt[1]<=top){
		clr();
		dfs(1);
	}
	for(int i=1;i<=top;++i){
		reverse(a[i].begin(),a[i].end());
		nxt[i]=i+1;
	}
	while(nxt[1]<=top){
		clr();
		dfs(1);
	}
	int ans=0;
//	for(int i=1;i<=n;++i) printf("(%d)",vis[i]);
	for(int i=1;i<=top;++i)
		for(auto x:a[i])
			if(!vis[x]) ++ans;
	printf("! %d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX_N=1024;
int a[MAX_N];
bool vis[MAX_N];
bool query(int x){
	static char s1[MAX_N];
	printf("? %d\n",x);
	fflush(stdout);
	scanf("%s",s1);
	return s1[0]=='Y';
}
void clr(){ puts("R"); fflush(stdout); }
int main(){
	int n,k; scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;j+=k){
			clr();
			for(int t=j;t<min(j+k-1,i);++t)
				query(t);
			vis[i]|=query(i);
		}
	int ans=0;
	for(int i=1;i<=n;++i)
		if(!vis[i]) ++ans;
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,k,g,top;
vector<int> a[1030];
bool query(int x){
	printf("? %d\n",x);
	fflush(stdout);
	static char s[15];
	scanf("%s",s);
	return s[0]=='Y';
}
void clr(){ puts("R"); fflush(stdout); }
void finish(int x){ printf("! %d\n",x); exit(0); }
void ask(int i){
	vector<int> b;
	for(auto x:a[i]){
		if(!query(x)) b.push_back(x);
	}
	a[i]=b;
}
void shift2(vector<int>& a){
	int x=a[0],y=a[1];
	for(int i=2;i<a.size();++i)
		a[i-2]=a[i];
	a[(int)a.size()-2]=x;
	a[(int)a.size()-1]=y;
}
void solve(vector<int> a){
	if(a.size()<=2){
		clr();
		for(auto x:a)
			ask(x);
		return;
	}
	vector<int> x(a.begin(),a.begin()+a.size()/2);
	vector<int> y(a.begin()+a.size()/2,a.end());
	solve(x); solve(y);
	for(int i=0;i<x.size()/2;++i){
		clr();
		for(int j=0;j<x.size();++j){
			ask(x[j]); ask(y[j]);
		}
		clr();
		ask(x[0]); ask(y.back());
		shift2(x);
	}
}
int main(){
	scanf("%d%d",&n,&k); g=max(k/2,1); top=n/g;
	for(int i=1;i<=top;++i)
		for(int j=(i-1)*g+1;j<=i*g;++j)
			a[i].push_back(j);
	vector<int> x;
	for(int i=1;i<=top;++i) x.push_back(i);
	solve(x);
	int ans=0;
	for(int i=1;i<=top;++i)
		ans+=(int)a[i].size();
	finish(ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX_N=1024;
int a[MAX_N];
bool vis[MAX_N];
bool query(int x){
	static char s1[MAX_N];
	printf("? %d\n",x);
	fflush(stdout);
	scanf("%s",s1);
	return s1[0]=='Y';
}
void clr(){ puts("R"); fflush(stdout); }
int main(){
	int n,k; scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		for(int j=1;j<i;j+=k){
			clr();
			for(int t=j;t<min(j+k-1,i);++t)
				query(t);
			vis[i]|=query(i);
		}
	int ans=0;
	for(int i=1;i<=n;++i)
		if(!vis[i]) ++ans;
	printf("! %d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define maxn 4096
using namespace std;
int n,k;
vector<int> blocks[maxn];
bool sm[maxn];
int main() {
    scanf("%d %d",&n,&k);
    int t=k;
    int r=n/t;
    for(int i=0;i<r;i++) {
        for(int j=1;j<=t;j++) {
            blocks[i].push_back(j+i*t);
        }
    }
    for(int i=0;i<r;i++) {
        int d=0;
        printf("R\n");
        fflush(stdout);
        for(int w=0;w<r;w++) {
            int p=(i+d+r)%r;
            for(int j=0;j<t;j++) {
                if(!sm[blocks[p][j]]) {
                    printf("? %d\n",blocks[p][j]);
                    fflush(stdout);
                    char g[2];
                    scanf("%s",g);
                    if(g[0]=='Y') sm[blocks[p][j]]=true;
                }
            }
            if(d>=0) d++;
            d=-d;
        }
    }
    int d=0;
    for(int i=1;i<=n;i++) if(!sm[i]) d++;
    printf("! %d\n",d);
    fflush(stdout);
    return 0;
}


#include<bits/stdc++.h>
#define maxn 4096
using namespace std;
int n,k;
vector<int> blocks[maxn];
bool sm[maxn];
int main() {
    scanf("%d %d",&n,&k);
    int t=k;
    if(t==0) t=1;
    int r=n/t;
    for(int i=0;i<r;i++) {
        for(int j=1;j<=t;j++) {
            blocks[i].push_back(j+i*t);
        }
    }
    for(int i=0;i<r;i++) {
        int d=0;
        printf("R\n");
        fflush(stdout);
        for(int w=0;w<r;w++) {
            int p=i+d;
            if(p<0) p+=r;
            for(int j=0;j<t;j++) {
                if(!sm[blocks[p][j]]) {
                    printf("? %d\n",blocks[p][j]);
                    fflush(stdout);
                    char g[2];
                    scanf("%s",g);
                    if(g[0]=='Y') sm[blocks[p][j]]=true;
                }
            }
            if(d>=0) d++;
            d=-d;
        }
    }
    int d=0;
    for(int i=1;i<=n;i++) if(!sm[i]) d++;
    printf("! %d\n",d);
    fflush(stdout);
    return 0;
}


#include<bits/stdc++.h>
#define maxn 4096
using namespace std;
int n,k;
vector<int> blocks[maxn];
bool sm[maxn];
int main() {
    scanf("%d %d",&n,&k);
    int t=k;
    if(t==0) t=1;
    int r=n/t;
    for(int i=0;i<r;i++) {
        for(int j=1;j<=t;j++) {
            blocks[i].push_back(j+i*t);
        }
    }
    for(int i=0;i<r;i++) {
        int d=0;
        printf("R\n");
        fflush(stdout);
        for(int w=0;w<r;w++) {
            int p=i+d;
            if(p<0) p+=r;
            for(int j=0;j<t;j++) {
                if(!sm[blocks[p][j]]) {
                    printf("? %d\n",blocks[p][j]);
                    fflush(stdout);
                    char g;
                    scanf("%c",&g);
                    if(g=='Y') sm[blocks[p][j]]=true;
                }
            }
            if(d>=0) d++;
            d=-d;
        }
    }
    int d=0;
    for(int i=1;i<=n;i++) if(!sm[i]) d++;
    printf("! %d\n",d);
    fflush(stdout);
    return 0;
}


#include<bits/stdc++.h>
#define maxn 4096
using namespace std;
int n,k;
vector<int> blocks[maxn];
bool sm[maxn];
int main() {
    scanf("%d %d",&n,&k);
    int t=k/2;
    if(t==0) t++;
    int r=n/t;
    for(int i=0;i<r;i++) {
        for(int j=1;j<=t;j++) {
            blocks[i].push_back(j+i*r);
        }
    }
    for(int i=0;i<r;i++) {
        int d=0;
        for(int w=0;w<r;w++) {
            printf("R\n");
            fflush(stdout);
            int p=i+d;
            if(p<0) p+=r;
            for(int j=0;j<t;j++) {
                if(!sm[blocks[p][j]]) {
                    printf("? %d\n",blocks[p][j]);
                    fflush(stdout);
                    char g;
                    scanf("%c",&g);
                    if(g=='Y') sm[blocks[p][j]]=true;
                }
            }
            if(d>=0) d++;
            d=-d;
        }
    }
    int d=0;
    for(int i=1;i<=n;i++) if(!sm[i]) d++;
    printf("! %d\n",d);
    fflush(stdout);
    return 0;
}


#include<bits/stdc++.h>
#define maxn 4096
using namespace std;
int n,k;
vector<int> blocks[maxn];
bool sm[maxn];
int main() {
    scanf("%d %d",&n,&k);
    int t=k/2;
    if(t==0) t=1;
    int r=n/t;
    for(int i=0;i<r;i++) {
        for(int j=1;j<=t;j++) {
            blocks[i].push_back(j+i*t);
        }
    }
    for(int i=0;i<r;i++) {
        int d=0;
        printf("R\n");
        fflush(stdout);
        for(int w=0;w<r;w++) {
            int p=i+d;
            if(p<0) p+=r;
            for(int j=0;j<t;j++) {
                if(!sm[blocks[p][j]]) {
                    printf("? %d\n",blocks[p][j]);
                    fflush(stdout);
                    char g;
                    scanf("%c",&g);
                    if(g=='Y') sm[blocks[p][j]]=true;
                }
            }
            if(d>=0) d++;
            d=-d;
        }
    }
    int d=0;
    for(int i=1;i<=n;i++) if(!sm[i]) d++;
    printf("! %d\n",d);
    fflush(stdout);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxN = 1200;

int n, m, B, mx;
bool vis[maxN + 1];
char ch[2];

inline bool query(int x)
{
	printf("? %d\n", x);
	fflush(stdout);
	scanf("%s", ch);
	return ch[0] == 'Y';
}

int main()
{
	scanf("%d %d", &n, &m);

	int ans = n;
	if(m == 1)
	{
		for(int i = 1; i <= n; i++)
			for(int j = 1; j < i; j++)
			{
				if(vis[j]) continue;
				query(j);
				if(query(i)) { ans --; vis[i] = true; break; }
			}
		printf("! %d\n", ans);
		fflush(stdout);
		return 0;
	}

	B = m / 2, mx = n / B;
	for(int i = 0; i < mx / 2; i++)
	{
		printf("R\n");
		fflush(stdout);
		int d = 0;
		for(int j = 0; j < mx; j++)
		{
			int x = (i + d + mx) % mx;
			for(int k = x * B + 1; k <= (x + 1) * B; k++)
				if(!vis[k] && query(k)) vis[k] = true, ans --;
			if(d >= 0) d ++;
			d = -d;
		}
	}

	printf("! %d\n", ans);
	fflush(stdout);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long

const int N = 2333;
int n, k, s, ans, cnt;
bool f[N];
bool ask(int x){
	// ++cnt;
	// return 0;
	printf("? %d\n", x), fflush(stdout);
	char c;
	while(!isalpha(c=getchar()));
	return c=='Y';
}
int main() {
	scanf("%d%d", &n, &k);
	if(k==1){
		for(int i=1; i<=n; ++i){
			bool o=0;
			for(int j=1; j<i; ++j){
				ask(j);
				o|=ask(i);
			}
			ans+=!o;
		}
		printf("! %d\n", ans), fflush(stdout);
		return 0;
	}
	k/=2, s=n/k;
	for(int i=1; i<s; ++i) for(int j=1; j<=s-i && j<=i; ++j){
		printf("R\n"), fflush(stdout);
		for(int x=j; x<=s; x+=i){
			// printf("[%d]", x);
			for(int y=(x-1)*k+1; y<=x*k; ++y) f[y]|=ask(y);
		}
	}
	for(int i=1; i<=n; ++i) ans+=!f[i];
	printf("! %d\n", ans), fflush(stdout);
	// printf(">> %d %d\n", cnt, 3*n*n/k/4);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
#define ll long long

const int N = 2333;
int n, k, s, ans, cnt;
bool f[N];
bool ask(int x){
	// ++cnt;
	// return 0;
	printf("? %d\n", x), fflush(stdout);
	char c;
	while(!isalpha(c=getchar()));
	return c=='Y';
}
int main() {
	scanf("%d%d", &n, &k);
	if(k==1){
		for(int i=1; i<=n; ++i){
			bool o=0;
			for(int j=1; j<i; ++j){
				ask(j);
				o|=ask(i);
			}
			ans+=!o;
		}
		printf("! %d\n", ans), fflush(stdout);
		return 0;
	}
	k/=2, s=n/k;
	for(int i=1; i<s; ++i) for(int j=1; j<=s-i && j<=i; ++j){
		printf("R\n"), fflush(stdout);
		for(int x=j; x<=s; x+=i){
			// printf("[%d]", x);
			for(int y=(x-1)*k+1; y<=x*k; ++y) f[y]|=ask(y);
		}
	}
	for(int i=1; i<=n; ++i) ans+=!f[i];
	printf("%d\n", ans);
	// printf(">> %d %d\n", cnt, 3*n*n/k/4);
	return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            if (num <= k + 1){
                cout << "R" << endl;
                continue;
            }
            if (num > k * 2){
                mak (i);
                cout << "R" << endl;
                continue;
            }
            cout << "R" << endl;
            cur = (i - t + M) % M;
            mak (cur);
            mak (i);
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            if (num <= k + 1){
                cout << "R" << endl;
                continue;
            }
            if (num > k * 2){
                mak (i);
                cout << "R" << endl;
                continue;
            }
            cur = (i + t) % M;
            while (cur != i){
                mak (cur);
                cur = (cur + t) % M;
            }
            mak (i);
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            if (num <= k + 1){
                cout << "R" << endl;
                continue;
            }
            cout << "R" << endl;
            cur = (i - t + M) % M;
            mak (cur);
            mak (i);
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            /*if (num <= k + 1){
                cout << "R" << endl;
                continue;
            }*/
            if (num > k * 2){
                mak (i);
                cout << "R" << endl;
                continue;
            }
            cur = (i + t) % M;
            while (cur != i){
                mak (cur);
                cur = (cur + t) % M;
            }
            mak (i);
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            if (num <= k + 1){
                cout << "R" << endl;
                continue;
            }
            if (num > k * 2){
                mak (i);
                cout << "R" << endl;
                continue;
            }
            cout << "R" << endl;
            cur = (i + t) % M;
            while (cur != i){
                mak (cur);
                cur = (cur + t) % M;
            }
            mak (i);
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
//#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/
using namespace std;

const int N = 300005, MOD = 1e9 + 7;

int n, k;
vector < int > v[N];
bool F[N];
bool fix[N];
char ch;
int num;

void mak (int cur){
    for (int x : v[cur])
        if (F[x] == 1){
            cout << "? " << x << endl;
            num++;
            cin >> ch;
            if (ch == 'Y'){
                F[x] = 0;
            }
        }
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n >> k;
    int K = (k + 1) / 2;
    int M = (n - 1) / K + 1;
    for (int i = 0; i < n; i++)
        v[i / K].pb (i + 1);
    for (int i = 1; i <= n; i++)
        F[i] = 1;
    for (int t = 1; t * 2 <= M; t++){
        for (int i = 0; i < M; i++)
            fix[i] = 0;
        for (int i = 0; i < M; i++){
            if (fix[i] == 1)
                break;
            int cur = i;
            num = 0;
            while (fix[cur] == 0){
                fix[cur] = 1;
                mak (cur);
                cur += t;
                if (cur >= M)
                    cur -= M;
            }
            if (num > k){
                mak (i);
            }
            cout << "R" << endl;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if (F[i] == 1)
            ans++;
    cout << "! " << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k;

int main() {
  cin >> n >> k;
  vector<vector<int>> cur(n / k);
  int cnt = 3 * n * n / (2 * k);
  auto ask = [&](int x) {
    assert(cnt);
    cnt--;
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'Y');
  };
  auto rs = [&] () {
    cout << "R" << endl;
  };
  range(i, 0, n / k) {
    range(j, i * k, (i + 1) * k) {
      if(ask(j)) cur[i].push_back(j);
    }
    assert(!cur[i].empty());
    rs();
  }
  int s = n / k;
  vector<vector<vector<int>>> to(s, vector<vector<int>>(s));
  range(i, 0, s) {
    range(j, 0, i) {
      vector<int> a, b, x, y;
      range(t, 0, (int) cur[i].size() / 2) a.push_back(cur[i][t]);
      range(t, cur[i].size() / 2, (int) cur[i].size()) b.push_back(cur[i][t]);
      range(t, 0, (int) cur[j].size() / 2) x.push_back(cur[j][t]);
      range(t, cur[j].size() / 2, (int) cur[j].size()) y.push_back(cur[j][t]);
      set<int> ri;
      range(u, 0, 2) {
        range(v, 0, 2) {
          for(int c : x) ask(c);
          for(int c : a) {
            if(!ask(c)) ri.insert(c);
          }
          rs();
          swap(a, b);
        }
        swap(x, y);
      }
      for(int c : cur[i]) if(ri.find(c) != ri.end()) to[i][j].push_back(c);
    }
  }
  int res = 0;
  range(i, 0, s) {
    set<int> r;
    range(j, 0, i) {
      for(int t : to[i][j]) r.insert(t);
    }
    for(int j : cur[i]) res += r.find(j) == r.end();
  }
  cout << "! " << res << endl;
  return 0;
}


/**
 *    author:  tourist
 *    created: 02.02.2020 18:33:41
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  auto Ask = [&](int x) {
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'Y');
  };
  auto DoR = [&]() {
    cout << "R" << endl;
  };
  int b = max(k / 2, 1);
  int cnt = n / b;
  vector<int> dup(n, 0);
  vector<vector<int>> asked(cnt, vector<int>(cnt, 0));
  for (int i = 0; i < cnt; i++) {
    for (int j = i + 1; j < cnt; j++) {
      if (!asked[i][j]) {
        int x = i, y = j;
        for (int t = 0; t < b; t++) {
          if (Ask(x * b + t)) {
            dup[x * b + t] = 1;
          }
        }
        while (true) {
          for (int t = 0; t < b; t++) {
            if (Ask(y * b + t)) {
              dup[y * b + t] = 1;
            }
          }
          asked[x][y] = 1;
          int z = y + 1;
          while (z < cnt && asked[y][z]) {
            ++z;
          }
          if (z == cnt) {
            break;
          }
          x = y;
          y = z;
        }
        DoR();
      }
    }
  }
  cout << "! " << n - accumulate(dup.begin(), dup.end(), 0) << '\n';
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k;

int main() {
  cin >> n >> k;
  vector<vector<int>> cur(n / k);
  auto ask = [&](int x) {
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'N');
  };
  auto rs = [&] () {
    cout << "R" << endl;
  };
  range(i, 0, n / k) {
    range(j, i * k, (i + 1) * k) {
      if(ask(j)) cur[i].push_back(j);
    }
    assert(!cur[i].empty());
    rs();
  }
  int s = n / k;
  vector<vector<vector<int>>> to(s, vector<vector<int>>(s));
  range(i, 0, s) {
    range(j, 0, i) {
      vector<int> a, b, x, y;
      range(t, 0, (int) cur[i].size() / 2) a.push_back(cur[i][t]);
      range(t, cur[i].size() / 2, (int) cur[i].size()) b.push_back(cur[i][t]);
      range(t, 0, (int) cur[j].size() / 2) x.push_back(cur[j][t]);
      range(t, cur[j].size() / 2, (int) cur[j].size()) y.push_back(cur[j][t]);
      set<int> ri;
      range(u, 0, 2) {
        range(v, 0, 2) {
          for(int c : x) ask(c);
          for(int c : a) {
            if(!ask(c)) ri.insert(c);
          }
          rs();
          swap(a, b);
        }
        swap(x, y);
      }
      for(int c : cur[i]) if(ri.find(c) != ri.end()) to[i][j].push_back(c);
    }
  }
  int res = 0;
  range(i, 0, s) {
    set<int> r;
    range(j, 0, i) {
      for(int t : to[i][j]) r.insert(t);
    }
    for(int j : cur[i]) res += r.find(j) == r.end();
  }
  cout << "! " << res << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k;

int main() {
  cin >> n >> k;
  vector<vector<int>> cur(n / k);
  int cnt = 3 * n * n / (2 * k);
  auto ask = [&](int x) {
    assert(cnt);
    cnt--;
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'Y');
  };
  assert(ask(0));
  rs();
  auto rs = [&] () {
    cout << "R" << endl;
  };
  range(i, 0, n / k) {
    range(j, i * k, (i + 1) * k) {
      cout << "? " << j + 1 << endl;
      string foo;
      cin >> foo;
      cout << foo << endl;
      if(foo[0] == 'Y') cur[i].push_back(j);
    }
    assert(!cur[i].empty());
    rs();
  }
  int s = n / k;
  vector<vector<vector<int>>> to(s, vector<vector<int>>(s));
  range(i, 0, s) {
    range(j, 0, i) {
      vector<int> a, b, x, y;
      range(t, 0, (int) cur[i].size() / 2) a.push_back(cur[i][t]);
      range(t, cur[i].size() / 2, (int) cur[i].size()) b.push_back(cur[i][t]);
      range(t, 0, (int) cur[j].size() / 2) x.push_back(cur[j][t]);
      range(t, cur[j].size() / 2, (int) cur[j].size()) y.push_back(cur[j][t]);
      set<int> ri;
      range(u, 0, 2) {
        range(v, 0, 2) {
          for(int c : x) ask(c);
          for(int c : a) {
            if(!ask(c)) ri.insert(c);
          }
          rs();
          swap(a, b);
        }
        swap(x, y);
      }
      for(int c : cur[i]) if(ri.find(c) != ri.end()) to[i][j].push_back(c);
    }
  }
  int res = 0;
  range(i, 0, s) {
    set<int> r;
    range(j, 0, i) {
      for(int t : to[i][j]) r.insert(t);
    }
    for(int j : cur[i]) res += r.find(j) == r.end();
  }
  cout << "! " << res << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k;

int main() {
  cin >> n >> k;
  vector<vector<int>> cur(n / k);
  int cnt = 3 * n * n / (2 * k);
  auto ask = [&](int x) {
    assert(cnt);
    cnt--;
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'Y');
  };
  auto rs = [&] () {
    cout << "R" << endl;
  };
  range(i, 0, n / k) {
    range(j, i * k, (i + 1) * k) {
      cout << "? " << j + 1 << endl;
      string foo;
      cin >> foo;
      if(foo[0] == 'Y') cur[i].push_back(j);
    }
    assert(!cur[i].empty());
    rs();
  }
  int s = n / k;
  vector<vector<vector<int>>> to(s, vector<vector<int>>(s));
  range(i, 0, s) {
    range(j, 0, i) {
      vector<int> a, b, x, y;
      range(t, 0, (int) cur[i].size() / 2) a.push_back(cur[i][t]);
      range(t, cur[i].size() / 2, (int) cur[i].size()) b.push_back(cur[i][t]);
      range(t, 0, (int) cur[j].size() / 2) x.push_back(cur[j][t]);
      range(t, cur[j].size() / 2, (int) cur[j].size()) y.push_back(cur[j][t]);
      set<int> ri;
      range(u, 0, 2) {
        range(v, 0, 2) {
          for(int c : x) ask(c);
          for(int c : a) {
            if(!ask(c)) ri.insert(c);
          }
          rs();
          swap(a, b);
        }
        swap(x, y);
      }
      for(int c : cur[i]) if(ri.find(c) != ri.end()) to[i][j].push_back(c);
    }
  }
  int res = 0;
  range(i, 0, s) {
    set<int> r;
    range(j, 0, i) {
      for(int t : to[i][j]) r.insert(t);
    }
    for(int j : cur[i]) res += r.find(j) == r.end();
  }
  cout << "! " << res << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, k;

int main() {
  cin >> n >> k;
  vector<vector<int>> cur(n / k);
  auto ask = [&](int x) {
    cout << "? " << x + 1 << endl;
    string foo;
    cin >> foo;
    return (foo[0] == 'Y');
  };
  assert(ask(0));
  auto rs = [&] () {
    cout << "R" << endl;
  };
  rs();
  range(i, 0, n / k) {
    range(j, i * k, (i + 1) * k) {
      if(ask(j)) cur[i].push_back(j);
    }
    assert(!cur[i].empty());
    rs();
  }
  int s = n / k;
  vector<vector<vector<int>>> to(s, vector<vector<int>>(s));
  range(i, 0, s) {
    range(j, 0, i) {
      vector<int> a, b, x, y;
      range(t, 0, (int) cur[i].size() / 2) a.push_back(cur[i][t]);
      range(t, cur[i].size() / 2, (int) cur[i].size()) b.push_back(cur[i][t]);
      range(t, 0, (int) cur[j].size() / 2) x.push_back(cur[j][t]);
      range(t, cur[j].size() / 2, (int) cur[j].size()) y.push_back(cur[j][t]);
      set<int> ri;
      range(u, 0, 2) {
        range(v, 0, 2) {
          for(int c : x) ask(c);
          for(int c : a) {
            if(!ask(c)) ri.insert(c);
          }
          rs();
          swap(a, b);
        }
        swap(x, y);
      }
      for(int c : cur[i]) if(ri.find(c) != ri.end()) to[i][j].push_back(c);
    }
  }
  int res = 0;
  range(i, 0, s) {
    set<int> r;
    range(j, 0, i) {
      for(int t : to[i][j]) r.insert(t);
    }
    for(int j : cur[i]) res += r.find(j) == r.end();
  }
  cout << "! " << res << endl;
  return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k,l;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}
void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}

int main(){
    scanf("%lld%lld",&N,&K);
    nk = N / K;
    if(K>=2)
        nk *= 2;

    fornum(i,1,nk){
        fornum(j,0,i){
            //if(j+i>=nk)
            //    break;
            k = j;
            queR();
            while(k<nk){
                l = k;
                while(l<N){
                    if(mk[l]==0){
                        string a = que(l + 1);
                        if(a[0]=='Y')
                            mk[l] = 1;
                    }
                    l += nk;
                }
                k += i;
            }
        }
    }
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    nk = N / K * 4;
    ll i, j, k,l;
    fornum(i,0,nk){
        fornum(j,i+1,nk){
            queR();
            if(j>=nk)
                break;
            k = i;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,3){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    nk = N / K * 4;
    ll i, j, k,l;
    fornum(i,0,nk){
        fornum(j,i+1,nk){
            queR();
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,3){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k,l;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}
void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}

int main(){
    scanf("%lld%lld",&N,&K);
    nk = N / K;
    if(K>=2)
        nk *= 2;

    fornum(i,1,nk){
        fornum(j,0,i){
            if(j+i>=nk)
                break;
            k = j;
            queR();
            while(k<N){
                l = k;
                while(l<N){
                    if(mk[l]==0){
                        string a = que(l + 1);
                        if(a[0]=='Y')
                            mk[l] = 1;
                    }
                    l += nk;
                }
                k += i;
            }
        }
    }
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    ll a = 0;
    for (a = 0; a * a < K;++a)
        ;
    nk = N / K * a;
    ll i, j, k, l;
    fornum(i,0,nk){
        if(i+a-1>=nk)
            break;
        fornum(j,i+1,nk){
            queR();
            k = i;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,a-1){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += a - 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}

int main(){
    scanf("%lld%lld",&N,&K);
    nk = N / K;
    if(K>=2)
        nk *= 2;
    fornum(i,0,nk){
        fornum(j,i+1,nk){
            queR();
            k = i;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            k = j;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
        }
    }
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    nk = N / K * 4;
    ll i, j, k, l;
    fornum(i,0,nk){
        if(i+3>=nk)
            break;
        fornum(j,i+1,nk){
            queR();
            k = i;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,3){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    nk = N / K * 4;
    ll i, j, k,l;
    fornum(i,0,nk){
        fornum(j,i+1,nk){
            queR();
            k = i;
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,3){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k,l;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}
void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}

int main(){
    scanf("%lld%lld",&N,&K);
    nk = N / K;
    if(K>=2)
        nk *= 2;

    fornum(i,1,nk){
        fornum(j,0,i){
            if(j+i>=nk)
                break;
            k = j;
            queR();
            while(k<nk){
                l = k;
                while(l<N){
                    if(mk[l]==0){
                        string a = que(l + 1);
                        if(a[0]=='Y')
                            mk[l] = 1;
                    }
                    l += nk;
                }
                k += i;
            }
        }
    }
    answer();
    return 0;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N,K,nk;
ll mk[2020];
ll i, j, k;

string que(ll n){
    string ret;
    printf("? %lld\n", n);
    fflush(stdout);
    cin >> ret;
    return ret;
}
void queR(){
    printf("R\n");
    fflush(stdout);
}

void answer(){
    ll n = 0;
    fornum(i,0,N){
        if(mk[i]==0)
            ++n;
    }
    printf("! %lld\n",n);
    fflush(stdout);
}
void k1(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a=que(i+1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b=que(j+1);
            if(b[0]=='Y')
                mk[j] = 1;
        }
    }
}
void k2(){
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            string a = que(i + 1);
            if(a[0]=='Y')
                mk[i] = 1;
            string b = que(j + 1);
            if(b[0]=='Y')
                mk[j] = 1;
            ++j;
            if(j==N)
                break;
            string c = que(j + 1);
            if(c[0]=='Y')
                mk[j] = 1;
        }
    }
}
void kn(){
    nk = N / K * 4;
    ll i, j, k,l;
    fornum(i,0,N){
        fornum(j,i+1,N){
            queR();
            while(k<N){
                if(mk[k]==0){
                    string a=que(k+1);
                    if(a[0]=='Y')
                        mk[k] = 1;
                }
                k += nk;
            }
            fornum(l,0,3){
                k = j + l;
                if(j+l==N)
                    break;
                while(k<N){
                    if(mk[k]==0){
                        string a=que(k+1);
                        if(a[0]=='Y')
                            mk[k] = 1;
                    }
                    k += nk;
                }
            }
            j += 2;
        }
    }
}

int main(){
    scanf("%lld%lld",&N,&K);
    if(K==1)
        k1();
    if(K==2)
        k2();
    if(K>=4)
        kn();
    answer();
    return 0;
}


#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

bool G[520][520],alv[1030];
int nb,r[520],rn,n,k;

void dfs(int x){
    for(int i=0;i<nb;i++)
        if(!G[x][i]&&x!=i) {
            G[x][i]=true;
            G[i][x]=true;
            dfs(i);
        }
    r[rn++]=x;
}

bool ask(int pos)
{
    cout << "? " << pos << endl << flush;
    char c; cin >> c;
    if (c == 'E') exit(0);
    return (c == 'Y');
}

int main(){
    cin>>n>>k;
    nb=n/k;
    dfs(0);
    for(int i=0;i<=rn;i++)
        for(int j=r[i]*k+1;j<=r[i]*k+k;j++)
            if(!alv[j]&&ask(j))
                alv[j]=true;
    cout << "! " << count(alv+1,alv+n+1, false)<< endl << flush;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

bool ask(int pos)
{
    cout << "? " << pos+1 << endl << flush;
    char c; cin >> c;
    if (c == 'E') exit(0);
    return (c == 'Y');
}

int main()
{
    int nbElem, memSize, nbBlocks;
    cin >> nbElem >> memSize;
    memSize>>=1;
    nbBlocks = nbElem / memSize;

    vector<bool> isAlive(nbElem, true);

    for (int startBlock = 0; startBlock < nbBlocks; ++startBlock) {
        int delta = 0;
        cout << "R" << endl << flush;
        for (int iDo = 0; iDo < nbBlocks; ++iDo) {
            int curBlock = (startBlock+delta+nbBlocks) % nbBlocks;
            int st = curBlock*memSize;
            for (int elem = st; elem < st+memSize; ++elem) {
                if (isAlive[elem]) {
                    if (ask(elem)) isAlive[elem] = false;
                }
            }

            if (delta >= 0) ++delta;
            delta = -delta;
        }
    }

    int nbAlive = count(isAlive.begin(), isAlive.end(), true);
    cout << "! " << nbAlive << endl << flush;
}


#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

bool G[520][520],alv[1030];
int nb,r[520],rn,n,k;

void dfs(int x){
    for(int i=0;i<nb;i++)
        if(!G[x][i]&&x!=i) {
            G[x][i]=true;
            G[i][x]=true;
            dfs(i);
        }
    r[rn++]=x;
}

bool ask(int pos)
{
    cout << "? " << pos << endl << flush;
    char c; cin >> c;
    return c == 'Y';
}

int main(){
    cin>>n>>k;
    k>>=1;
    nb=n/k;
    dfs(0);
    for(int i=0;i<rn;i++)
        for(int j=r[i]*k+1;j<=r[i]*k+k;j++)
            if(!alv[j]&&ask(j))
                alv[j]=true;
    cout << "! " << count(alv+1,alv+n+1, false)<< endl << flush;
    return 0;
}


import java.util.*;

public class tasks{
	public static void main(String args[]){
		Scanner input=new Scanner(System.in);
		int N=input.nextInt();
		int K=input.nextInt();
		int[] energies=new int[N*2];
		for(int i=0; i<N; i++){
			energies[i]=input.nextInt();
		}
		for(int i=N; i<2*N; i++){
			energies[i]=energies[i-N];
		}
		final int numChecks=N/K;
//		System.out.println(Arrays.toString(energies)+" "+numChecks);
		int se=N*N;
		int si=0;
		int temp=0;
		int ink=0;
		for(int i=0; i<N; i++){
			temp=0;
			ink=i;
			for(int j=0; j<numChecks; j++){
				temp+=energies[ink];
				ink+=K;
			}
//			System.out.println(temp);
			if(temp<se){
				se=temp;
				si=i;
			}
		}
		System.out.println(si+1);
	}
}


import java.util.*;

public class tasks{
	public static void main(String args[]){
		Scanner input=new Scanner(System.in);
		int N=input.nextInt();
		int K=input.nextInt();
		int[] energies=new int[N*2];
		for(int i=0; i<N; i++){
			energies[i]=input.nextInt();
		}
		for(int i=N; i<2*N; i++){
			energies[i]=energies[i-N];
		}
		final int numChecks=N/K;
		int se=N*N;
		int si=0;
		int temp=0;
		for(int i=0; i<N; i++){
			temp=0;
			for(int j=i; j<numChecks; j+=K){
				temp+=energies[i];
			}
//			System.out.println(temp);
			if(temp<se){
				se=temp;
				si=i;
			}
		}
		System.out.println(si+1);
	}
}


import java.util.*;

public class dimatasks{
	public static void main(String args[]){
		Scanner input=new Scanner(System.in);
		int N=input.nextInt();
		int K=input.nextInt();
		int[] energies=new int[N];
		for(int i=0; i<N; i++){
			energies[i]=input.nextInt();
		}
		if(K==1){
			System.out.println("1");
			return;
		}
		int min=Integer.MAX_VALUE;
		int minind=-1;
		for(int i=0; i<K; i++){
			int tot=0;
			for(int j=i; j<N; j=(j+K)%N){
				if(j==i && tot!=0){
					if(tot<min){
						min=Math.min(tot, min);
						minind=j;
					}
					break;
				}
				tot+=energies[j];
			}
		}

		System.out.println(minind+1);
		return;
	}
}


import java.util.Scanner;

public class p2_214 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int []array=new int[n];
        for(int i=0;i<array.length;i++)
            array[i]=in.nextInt();
        int length=(k);
        long min=Long.MAX_VALUE;
        long temp=0;
        int index=-1;
        for(int i=0;i<length;i++){
            temp=0l;
            for(int j=i;j<array.length;j+=k)
                temp+=array[j];
            if(temp<min){
                min=temp;
                index=i;
            }
        }
        System.out.println(index+1);
    }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        StringTokenizer tokenizer = new StringTokenizer(readFromSystemIn());
        int nTaks = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(tokenizer.nextToken());
        int [] tasksPwoer = new int[nTaks];
        for(int i=0; i<nTaks; i++){
            tasksPwoer[i] = Integer.parseInt(tokenizer.nextToken());
        }
        int min = 999999999;
        int index = 0;
        int numberOfTask = nTaks/k;
        for(int i=0; i<k; i++){
            int sum = 0;
            for(int j=i;j<nTaks;j+=k){
                int number = tasksPwoer[j];
                sum+=number;
            }
            if(sum < min){
                min = sum;
                index = i+1;
            }
        }
        System.out.println(index);
    }

    public static String readFromSystemIn() {
        StringBuilder text = new StringBuilder();
        int read, N = 1024 * 1024;
        char[] buffer = new char[N];
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                read = br.read(buffer, 0, N);
                text.append(buffer, 0, read);

                if (read < N) {
                    break;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return text.toString();
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main{

    public static void main(String[] args) {
        StringTokenizer tokenizer = new StringTokenizer(readFromSystemIn());
        int nTaks = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(tokenizer.nextToken());
        int [] tasksPwoer = new int[nTaks];
        for(int i=0; i<nTaks; i++){
            tasksPwoer[i] = Integer.parseInt(tokenizer.nextToken());
        }
        int min = 999999999;
        int index = 0;
        for(int i=0; i<k; i++){
            if(tasksPwoer[i]+tasksPwoer[i+k-1] < min){
                min = tasksPwoer[i]+tasksPwoer[i+k-1];
                index = i;
            }
        }
        System.out.println(index);
    }

    public static String readFromSystemIn() {
        StringBuilder text = new StringBuilder();
        int read, N = 1024 * 1024;
        char[] buffer = new char[N];
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                read = br.read(buffer, 0, N);
                text.append(buffer, 0, read);

                if (read < N) {
                    break;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return text.toString();
    }
}


import java.io.*;
import java.util.*;

public class B implements Runnable {

	private void solve() throws IOException {
		int n = nextInt(), k = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = nextInt();
		int min = Integer.MAX_VALUE, ans = 0;
		for (int i = 0; i < k; i++) {
			int cur = 0;
			for (int j = i; j < n; j+= k) cur += a[j];
			if (cur < min) {
				min = cur;
				ans = i;
			}
		}
		print(ans + 1);
	}

	public static void main(String[] args) {
		new B().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(261);
		}
	}

	void halt() {
		writer.close();
		System.exit(0);
	}

	void print(Object... objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	void println(Object... objects) {
		print(objects);
		writer.println();
	}

	String nextLine() throws IOException {
		return reader.readLine();
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}

	int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author smith
 */
public class B {

    public static void main(String Args[]) throws IOException{
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st = new StringTokenizer(br.readLine());
     int n = Integer.valueOf(st.nextToken());
     int k = Integer.valueOf(st.nextToken());
     st = new StringTokenizer(br.readLine());
     int numeros[] = new int[n];
     int mejores[] = new int[n];
     int mejor=Integer.MAX_VALUE;
     int mejorpos=0;
     for(int i=0;i<n;i++){
         numeros[i]=Integer.valueOf(st.nextToken());
     }

     prin:
     for(int i=0;i<n;i++){
         if (mejores[i]!=0){
             mejores[i]+=mejores[i%n];
             continue;
         }
         int mejortmp=numeros[i];
         int j= (i-k);
         while(j>=0){
             mejortmp+=(numeros[j]);
             mejores[j]=mejortmp;
             if (mejortmp>=mejor){
                 continue prin;
             }
             j-=k;
         }
         j=i+(((n-i-1)/k)*k);
         //System.out.println(j+" "+i);
         while(j>i){
             mejortmp+=(numeros[j]);
             if (mejores[j]==0){
                mejores[j]=mejortmp;
             }
             if (mejortmp>=mejor){
                 continue prin;
             }
             j-=k;
         }
         if (mejortmp<mejor){
             mejor=mejortmp;
             mejorpos=i;
         }
     }
        System.out.println(mejorpos+1);
 }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author smith
 */
public class B {

    public static void main(String Args[]) throws IOException{
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     StringTokenizer st = new StringTokenizer(br.readLine());
     int n = Integer.valueOf(st.nextToken());
     int k = Integer.valueOf(st.nextToken());
     st = new StringTokenizer(br.readLine());
     int numeros[] = new int[n];
     int mejor=Integer.MAX_VALUE;
     int mejorpos=0;
     for(int i=0;i<n;i++){
         numeros[i]=Integer.valueOf(st.nextToken());
     }
        //System.out.println("**");
     prin:
     for(int i=0;i<n;i++){
         int mejortmp=numeros[i];
         int j= (i+k)%n;
         while(j<n){
             mejortmp+=(numeros[j]);
             if (mejortmp>=mejor){
                 continue prin;
             }
             j+=k;
         }
         j=j%n;
         while(j<i){
             mejortmp+=(numeros[j]);
             if (mejortmp>=mejor){
                 continue prin;
             }
             j+=k;
         }
         if (mejortmp<mejor){
             mejor=mejortmp;
             mejorpos=i;
         }
     }
        System.out.println(mejorpos+1);
 }

}


import java.util.Scanner;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author smith
 */
public class B {

    public static void main(String Args[]){
     Scanner sc = new Scanner(System.in);
     int n = sc.nextInt();
     int k = sc.nextInt();
     int numeros[] = new int[n];
     int mejor=Integer.MAX_VALUE;
     int mejorpos=0;
     for(int i=0;i<n;i++){
         numeros[i]=sc.nextInt();
     }
     prin:
     for(int i=0;i<n;i++){
         int mejortmp=numeros[i];
         int j= (i+k)%n;
         while(j<n){
             mejortmp+=(numeros[j]);
             if (mejortmp>=mejor){
                 continue prin;
             }
             j+=k;
         }
         j=j%n;
         while(j<i){
             mejortmp+=(numeros[j]);
             if (mejortmp>=mejor){
                 continue prin;
             }
             j+=k;
         }
         if (mejortmp<mejor){
             mejor=mejortmp;
             mejorpos=i;
         }
     }
        System.out.println(mejorpos+1);
 }

}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.util.Stack;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.TreeSet;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.BitSet;
import java.util.Random;
import java.util.ArrayDeque;
import java.math.*;
import java.util.List;
import java.util.Iterator;
import java.io.*;
public class Main{
    final static boolean DEBUG=false;
    static InputStream inputStream ;
    static OutputStream outputStream ;
    static InputReader in ;
    static OutputWriter outt ;
    static FileInputStream fstream ;;
    static DataInputStream in1;
    static BufferedReader x1 ;
    static FileOutputStream out ;
    String newLine="\n";
    static HashMap<Long,Integer> powers=new HashMap<Long,Integer>();
    static long primes[]=generatePrimes(1000000);
    static int LL=primes.length;
    static HashMap<Long,Integer> po=new HashMap<Long,Integer>();
        static StringBuilder outtt=new StringBuilder();

        public static void main(String []args)throws IOException{
        if(!DEBUG){
            inputStream = System.in;
            outputStream = System.out;
            in = new InputReader(inputStream);
            outt = new OutputWriter(outputStream);
        }
        else{
            fstream = new FileInputStream("input.txt");
            in1 = new DataInputStream(fstream);
            x1 = new BufferedReader(new InputStreamReader(in1));
            out = new FileOutputStream(new File("output.txt"));
        }
       Main Solver=new Main();
        int T;

            T=1;
        while(T-->0)
            Solver.solve();
            outt.print(outtt);
            if(!DEBUG)
            outt.close();
        else
            out.close();

 }
 public void solve()throws IOException{
            int N=in.readInt();
            int K=in.readInt();
            int a[]=new int[N];
            for(int i=0;i<N;i++)
                a[i]=in.readInt();
            int X[]=new int[K];
            for(int i=0;i<N;i++){
                X[i%K]+=a[i];
            }
            int min=Integer.MAX_VALUE;
            int ind=-1;
            for(int i=0;i<K;i++){
                if(X[i]<min){
                    min=X[i];
                    ind=i+1;
                }
            }
            outtt.append(ind);
        }

         static long pow(long n, long exp,long mod){
            long prod = 1;
            while (exp > 0){
                if ((exp & 1) != 0){
                    prod *= n;
                    if(prod>=mod)
                    prod=prod%mod;
                }
                n*=n;
                if(n>=mod)
                n=n%mod;
                exp >>= 1;
            }
            return prod;
 }
       static  long[] generatePrimes(int max) {
            boolean[] isComposite = new boolean[max + 1];
            for (int i = 2; i * i <= max; i++) {
                if (!isComposite [i]) {
                    for (int j = i; i * j <= max; j++) {
                        isComposite [i*j] = true;
                    }
                }
            }
            int numPrimes = 0;
            for (int i = 2; i <= max; i++) {
                if (!isComposite [i]) numPrimes++;
            }
           // HashMap<Integer,Boolean> primes=new HashMap<Integer,Boolean>();
           long primes[]=new long[numPrimes];
                int index = 0;
                for (int i = 2; i <= max; i++) {
                    if (!isComposite [i]) primes[index++]=i;;
                }
                return primes;
            }
    }
class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }
    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
        return readString();
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object...objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object...objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * Created by 875k on 12/25/13.
 */
public class CF214B {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tok = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(tok.nextToken());
        int k = Integer.parseInt(tok.nextToken());
        int[] a = new int[n];
        tok = new StringTokenizer(br.readLine());
        for(int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(tok.nextToken());
        }
        int mn = Integer.MAX_VALUE;
        int mni = 0;
        for(int i = 0; i < k; i++) {
            int sum = 0;
            for(int j = 0; j < n; j += k) {
                sum += a[(i + j) % n];
            }
            if(sum < mn) {
                mn = sum;
                mni = i + 1;
            }
        }
        System.out.println(mni);
    }
}


import java.io.*;
import java.util.*;

public class Main {
//	static Scanner in; static int next() throws Exception {return in.nextInt();};
	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
//	static BufferedReader in;
	static PrintWriter out;

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		int n = next();
		int k = next();

		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = next();

		int[] s = new int[k];
		for (int i = 0; i < n; i++) s[i % k] += a[i];

		int min = 0;
		for (int i = 1; i < k; i++) if (s[i] < s[min]) min = i;

		out.println(min + 1);

		out.close();
	}
}


import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{

    private void doit(){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int [] data = new int[n];
            for(int i = 0; i < n; i++){
                data[i] = sc.nextInt();
            }
            int ind = -1, min = Integer.MAX_VALUE;
            for(int i = 0; i < k; i++){
                int sum = 0;
                for(int j = i; j < n; j += k){
                    sum += data[j];
                }
                if(min > sum){
                    min = sum;
                    ind = i;
                }
            }
            System.out.println(ind + 1);
        }
    }

    private void debug(Object... o) {
        System.out.println("debug = " + Arrays.deepToString(o));
    }

    public static void main(String[] args) {
        new Main().doit();
    }
}


import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{

    private void doit(){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int [] data = new int[n];
            for(int i = 0; i < n; i++){
                data[i] = sc.nextInt();
            }
            int ind = -1, min = 1 << 24;
            for(int i = 0; i < k; i++){
                int sum = 0;
                for(int j = k + i; j < n; j += k){
                    sum += data[j];
                }
                if(min > sum){
                    min = sum;
                    ind = i;
                }
            }
            System.out.println(ind + 1);
        }
    }

    private void debug(Object... o) {
        System.out.println("debug = " + Arrays.deepToString(o));
    }

    public static void main(String[] args) {
        new Main().doit();
    }
}


import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{

    private void doit(){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int k = sc.nextInt();
            int [] data = new int[n];
            for(int i = 0; i < n; i++){
                data[i] = sc.nextInt();
            }
            int ind = -1, min = Integer.MAX_VALUE;
            for(int i = 0; i < k; i++){
                int sum = 0;
                for(int j = k + i; j < n; j += k){
                    sum += data[j];
                }
                if(min > sum){
                    min = sum;
                    ind = i;
                }
            }
            System.out.println(ind + 1);
        }
    }

    private void debug(Object... o) {
        System.out.println("debug = " + Arrays.deepToString(o));
    }

    public static void main(String[] args) {
        new Main().doit();
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class R214B {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(System.out);
		String[] arS1 = br.readLine().split(" ");
		int n = Integer.parseInt(arS1[0]);
		int k = Integer.parseInt(arS1[1]);
		int[] ar = new int[n];
		String[] arS2 = br.readLine().split(" ");

		for(int i=0; i<n; i++){
			ar[i] = Integer.parseInt(arS2[i]);
		}
		int minSum = Integer.MAX_VALUE;
		int s=0;
		int start=0;
		while(s<k){
			int sum=0;
			int i=0;
			while(i<n){
				sum += ar[s+i];
				i+=k;
			}
			if(sum<minSum){
				minSum = sum;
				start = s;
			}
			s++;
		}
		pw.println(start+1);
		pw.flush();
	}

}


import java.io.*;
import java.util.*;

public class B214 {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer nk = new StringTokenizer(in.readLine());
		int n = Integer.parseInt(nk.nextToken());
		int k = Integer.parseInt(nk.nextToken());
		int tasks[] = new int[n];
		int power[] = new int[k];
		StringTokenizer st = new StringTokenizer(in.readLine());

		for (int i = 0; i < n; i++) tasks[i] = Integer.parseInt(st.nextToken());

		for (int i = 0; i < n; i++)
			power[i%k] += tasks[i];

		int min = Integer.MAX_VALUE;
		int minIndex = -1;

		for (int i = 0; i < k; i++) {
			if (power[i] < min) {
				min = power[i];
				minIndex = i+1;
			}
		}

		System.out.println(minIndex);
	}
}


import java.util.*;
import java.io.*;
public class a {
public static void main(String[] args) throws IOException
{
    //input.init(System.in);
    Scanner input = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    int n = input.nextInt(), k = input.nextInt();
    int[] data = new int[n];
    for(int i = 0; i<n; i++) data[i] = input.nextInt();
    int[] sum = new int[k];
    for(int i = 0; i<n; i++) sum[i%k] += data[i];
    int min = 987654321, mindex = 0;
    for(int i = 0; i<k; i++)
    {
        if(sum[i] < min)
        {
            min = sum[i];
            mindex = i;
        }
    }
    out.println(1+mindex);
    out.close();
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
}


import java.util.*;
import java.io.*;

public class A {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n + 1];
		int[] ans = new int[k];
		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
			ans[i % k] += a[i];
		}
		int mx = 0;
		for (int i = 0; i < k; i++) {
			if (ans[mx] > ans[i]) {
				mx = i;
			}
		}
		if (mx == 0) {
			out.print(k);
		} else {
			out.print(mx);
		}
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream f) {
			try {
				br = new BufferedReader(new InputStreamReader(f));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				return null;
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] arg) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;

public class A {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n + 1];
		int[] ans = new int[k];
		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
			ans[i % k] += a[i];
		}
		int mx = 1;
		for (int i = 0; i < k; i++) {
			if (ans[mx] > ans[i]) {
				mx = i;
			}
		}
		if (mx == 0) {
			out.print(k);
		} else {
			out.print(mx);
		}
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream f) {
			try {
				br = new BufferedReader(new InputStreamReader(f));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				return null;
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] arg) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;

public class A {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n + 1];
		int[] ans = new int[k];
		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
			ans[i % k] += a[i];
		}
		int mx = 1;
		for (int i = 0; i < k; i++) {
			if (ans[mx] > ans[i]) {
				mx = i;
			}
			//out.print(b)
		}
		if (mx == 0) {
			out.print(k);
		} else {
			out.print(mx);
		}
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream f) {
			try {
				br = new BufferedReader(new InputStreamReader(f));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				return null;
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] arg) {
		new A().run();
	}
}


import java.util.*;
import java.io.*;

public class A {
	FastScanner in;
	PrintWriter out;

	public void solve() throws IOException {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = new int[n + 1];
		int[] ans = new int[k];
		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
			ans[i % k] += a[i];
		}
		int mx = Math.min(1, k - 1);
		for (int i = 0; i < k; i++) {
			if (ans[mx] > ans[i]) {
				mx = i;
			}
			//out.print(b)
		}
		if (mx == 0) {
			out.print(k);
		} else {
			out.print(mx);
		}
	}

	public void run() {
		try {
			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(InputStream f) {
			try {
				br = new BufferedReader(new InputStreamReader(f));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				return null;
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] arg) {
		new A().run();
	}
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int anspos=0;
        int[] arr=new int[n];
        int[] sum=new int[k];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        for(int p=0;p<n;p++){
            sum[p%k]+=arr[p];
        }
        for(int m=0;m<k-1;m++){
            if(sum[m]<sum[m+1]){
                anspos=m;
            }
        }
        System.out.println(anspos+1);
    }
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int anspos=0;
        int min=0;
        int[] arr=new int[n];
        int[] sum=new int[k];
        for(int i=0;i<n;i++){
            arr[i]=in.nextInt();
        }
        for(int p=0;p<n;p++){
            sum[p%k]+=arr[p];

        }
        min=sum[0];
        for(int m=0;m<k;m++){
            if(sum[m]<min){
                min=sum[m];
                anspos=m;

            }
        }
        System.out.println(anspos+1);
    }
}


import java.util.*;
public class B {
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] power = new int[n];
        for (int i = 0; i < n; i++)
        {
            power[i] = sc.nextInt();
        }

        int times = n / k;

        int min = Integer.MAX_VALUE;
        int start = 0;
        for (int i = 0; i < k; i++)
        {
            int total = 0;
            int begin = 0;
            for (int j = 1; j <= times; j++)
            {
                total += power[i +  begin];
                begin = (begin + k) % n;
            }

            if (total < min)
            {
                min = total;
                start = i;
            }

        }

        System.out.println(start + 1);
    }
}


import java.util.*;
import java.io.*;

public class GuardsHiring {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		int best = 0, ind = 0;
		for(int i=0; i<n; i++){
			int s = 0;boolean f = false;
			for(int j=i; ; j=(j+k)%n){
				if(f && j>=i) break;
				s += a[j];
				if(j>=n-k-1){
					f = true;
				}
			}
			if(best<s){
				best = s;
				ind = i;
			}
		}
		System.out.println(ind+1);
	}
}


import java.util.*;
import java.io.*;

public class GuardsHiring {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		int best = 1000000000, ind = 0;
		for(int i=0; i<n; i++){
			int s = 0;boolean f = false;
			for(int j=i; ; j=(j+k)%n){
				if(f && j>=i) break;
				s += a[j];
				if(j>n-k-1){
					f = true;
				}
			}
			if(best>s){
				best = s;
				ind = i;
			}
		}
		System.out.println(ind+1);
	}
}


import java.util.*;
import java.io.*;

public class GuardsHiring {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		int best = 0, ind = 0;
		for(int i=0; i<n; i++){
			int s = 0;boolean f = false;
			for(int j=i; ; j=(j+k)%n){
				if(f && j>=i) break;
				s += a[j];
				if(j>n-k-1){
					f = true;
				}
			}
			if(best<s){
				best = s;
				ind = i;
			}
		}
		System.out.println(ind+1);
	}
}


import java.util.*;
import java.io.*;

public class GuardsHiring {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) a[i] = sc.nextInt();
		int best = 1000000000, ind = 0;
		boolean[] been = new boolean[n];
		for(int i=0; i<n; i++){
			int s = 0;boolean f = false;
			if(been[i]) continue;
			been[i] = true;
			for(int j=i; ; j=(j+k)%n){
				been[j] = true;
				if(f && j>=i) break;
				s += a[j];
				if(j>n-k-1){
					f = true;
				}
			}
			if(best>s){
				best = s;
				ind = i;
			}
		}
		System.out.println(ind+1);
	}
}


import java.util.*;
import java.io.*;

public class GuardsHiring {
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		int[] a = new int[n];
		int best = 0, ind = 0;
		for(int i=0; i<n; i++){
			int s = 0;boolean f = false;
			for(int j=i; ; j=(j+k)%n){
				if(f && j>i) break;
				s += a[j];
				if(j>=n-k){
					f = true;
				}
			}
			if(best<s){
				best = s;
				ind = i;
			}
		}
		System.out.println(ind+1);
	}
}


import java.util.Scanner;

public class DimaandTodoList
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; ++i)
		{
			a[i] = input.nextInt();
		}
		long res = 0;
		int idx = -1;
		long min = 100000001;
		for (int i = 0; i < k; ++i)
		{
			res = 0;
			for (int j = i; j < n; j += k)
			{
				res += a[j];
			}
			if (min > res)
			{
				min = res;
				idx = i;
			}
		}
		System.out.println(idx + 1);
	}
}


import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws IOException{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String[] split = reader.readLine().split(" ");
		int n = Integer.parseInt(split[0]);
		int k = Integer.parseInt(split[1]);
		int[] a = new int[n];
		int[] x = new int[n];
		boolean[] flag = new boolean[n];
		StringTokenizer tokenizer = new StringTokenizer (reader.readLine());
		for (int ii = 0; ii < n; ii++) {
			a[ii] = Integer.parseInt(tokenizer.nextToken());
		}
		int minimum = Integer.MAX_VALUE;
		int result = 0;
		for (int ii = 0; ii < n; ii++) {
			if (!flag[ii]) {
				int sum = 0;
				int jj = ii;
				while(jj < n) {

					sum = sum + a[jj];
					flag[jj] = true;
					jj = jj + k;
					//System.out.println("SUM : " + jj + " " + sum);
				}
				//System.out.println(ii + " " + sum);
				if (sum < minimum) {
					minimum = sum;
					result = ii;
				}
			}
		}
		System.out.println(result + 1);
	}
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.naming.BinaryRefAddr;

public class palin {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(System.out);
		Scanner scan = new Scanner(System.in);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt(), k = in.nextInt(), a[] = new int[n], f = 0, s = Integer.MAX_VALUE;
		for (int i = 0; i < a.length; i++) {
			a[i] = in.nextInt();
		}
		for (int i = 0; i < k; i++) {
			int t = 0;
			for (int j = i; j < n; j += k) {
				t += a[j];
			}
			if (t < s) {
				s = t;
				f = i;
			}
		}
		out.print(f + 1);
	}
}

class InputReader {
	BufferedReader br;
	StringTokenizer st;

	public InputReader(InputStream in) {
		br = new BufferedReader(new InputStreamReader(in));
		st = null;
	}

	public String next() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public float nextFloat() {
		return Float.parseFloat(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


import java.util.Scanner;
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        int n = in.nextInt();
        int k = in.nextInt();
        int[] a = new int[k];
        for (int i = 0; i < n; ++i) {
            int x = in.nextInt();
            a[i % k] += x;
        }
        int p = 0;
        for (int i = 1; i < k; ++i)
            if (a[p] > a[i])
                p = i;
        out.print(p + 1);
    }
}


import java.util.Scanner;

/**
 *
 * @author galyna.kriukova
 */
public class problemB {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] min = new int[k];
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            min[i % k] += a;
        }
        int minnow = min[0];
        int minindnow = 0;
        for (int i = 1; i<k; i++) {
            if (minnow > min[i]) {minindnow = i;}
        }
        System.out.println(minindnow+1);

        System.out.flush();
    }

}


import java.util.Scanner;

/**
 *
 * @author galyna.kriukova
 */
public class problemB {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] min = new int[k];
        for (int i = 0; i < n; i++) {
            min[i % k] += in.nextInt();
        }
        int minnow = min[0];
        int minindnow = 0;
        for (int i = 1; i<k; i++) {
            if (minnow > min[i]) {
                minindnow = i;
                minnow = min[i];
            }
        }
        System.out.println(minindnow+1);

        System.out.flush();
    }

}


import java.io.*;
import java.util.*;
import java.awt.*;
import java.math.*;

public class Main {
	static BufferedReader br = new BufferedReader( new InputStreamReader(System.in) );
	static StringTokenizer st = new StringTokenizer("");
	static String next()	throws Exception	{
		while	( !st.hasMoreTokens() )	st = new StringTokenizer( br.readLine() );
		return	st.nextToken();
	}

	public static void main(String [] asda)	throws Exception	{
	//	br = new BufferedReader( new InputStreamReader( new FileInputStream("in.txt") ) );
	//	PrintWriter out = new PrintWriter( new BufferedOutputStream( new FileOutputStream("out.txt") ) );
		PrintWriter out = new PrintWriter( new BufferedOutputStream(System.out) );
		//
		int N = Integer.parseInt( next() );
		int k = Integer.parseInt( next() );
		int v [] = new int [N];
	//	try	{
		for (int i = 0; i < N; i++)	{
			v[i] = Integer.parseInt( next() );
		}
	//	}	catch (Exception e)	{}
		int min = Integer.MAX_VALUE;
		int curr;
		int index = 1;
		int i, j = 0;
		for (i = 0; i < k; i++)	{
			curr = v[i];
			for (j = (i + k) % N;	j != i && curr < min; j = (j + k) % N )	{
				curr += v[j];
			}
			if	( j == i && curr < min )	{
				index = i + 1;
				min = curr;
			}
		}
		out.println( index );
		out.flush();
	//	br.close();
	//	out.close();
	}
}