to-be-changed-choosing-a-project
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

Singh is getting bored at work. He has a lot of ideas (N) to work on (as side projects) but is unable to choose one.

He chooses a random number (R) and lines up his ideas in a circle. He starts counting from first and removes the R^th idea in the circle until only one remains. Help him choose an idea to work on.

Input Format:

no_of_ideas random_number

Output Format:

idea_number

Constraints:

1 ≤ N ≤ 20

1 ≤ R ≤ 10000000

SAMPLE INPUT
5 3

SAMPLE OUTPUT
4

Explanation

List: {1,2,3,4,5}. Start counting from 1,

1 2 3 -> 3 removed

4 5 1 -> 1 removed

2 4 5 -> 5 removed

2 4 2 -> 2 removed

Remaining number: 4


N, R = [int(i) for i in input().split()]

r = 0
for i in range(1, N+1):
	r = (r+R)%i
print(r+1)


n,r = list(map(int, input().split()))
m,j = n,0
r -= 1
tmp = [i+1 for i in range(n)]
for i in range(n):
	j = (j+r)%m
	ans = tmp[j]
	tmp = tmp[:j]+tmp[j+1:]
	m -= 1	
print(ans)


n,k=list(map(int,input().split()))
ans=0
for i in range(1,n+1):
	ans=(ans+k)%i
print(ans+1)
	



def j(n, k):
	r = 0
	for i in range(1, n+1):
	    r = (r+k)%i
	return r+1
a,b=list(map(int,input().split()))
print(j(a,b))


n,r=list(map(int,input().split()))
nums = list(range(1,n+1))
idx = 0
while(len(nums)>1):
	idx+=(r-1)
	idx%=len(nums)
	del nums[idx]
print(nums[0])


#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright ? 2015 shivam <shivam@Infinite-Tsukuyomi>
#
# Distributed under terms of the MIT license.

n,r = list(map(int,input().split(' ')))
l = list(range(1,n+1))
idx = 0
r -= 1
ite = len(l) - 1
for i in range(ite):
	t = len(l)
	idx = (idx + r)%t
	l.pop(idx)
print(l[0])


def answer(total,skip):
	ans=0
	for i in range(2,total+1):
		ans = (ans+skip) %i
	return ans

def main():
	x,y=list(map(int,input().split()))
	print(answer(x,y)+1)

	
if __name__=="__main__":
	main()