Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

## Ants

To celebrate the New Year, the ants gather along a circle and play a game together. The queen announces a number, call it M and start by counting 1. In clockwise order, the ants continue to count the next numbers in turn. Who counts M has to go out of the circle. The next ant (in clockwise order) restarts counting from 1.

The game ends when there is only one ant left. This ant will get a new-year gift from the queen.

Given M and the number of ants in the circle, determine the lucky ant that will receive the new-year gift. The ants are numbered in clockwise order, starting from the queen of index 1.

### Input

• Line 1: a positive integer N that is the number of ants in the circle.
• Line 2: a postive integer M.

### Output

Only one line containing the lucky ant's index.

### Constraints

• 1 ≤ N ≤ 1012.3 ≤ M ≤ 106.
• M ≤ N.

### Example

```Input
7
3

Output
4

Output details
The ants 3 6 2 7 5 1 in turn have to go out of the circle.
Ant 4 is the lucky one!
```

 Được gửi lên bởi: VOJ Team Ngày: 2008-07-21 Thời gian chạy: 1s Giới hạn mã nguồn: 50000B Memory limit: 1536MB Cluster: Cube (Intel G860) Ngôn ngữ cho phép: ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM qobi SCM guile ST WHITESPACE Nguồn bài: VNOI Marathon '08 - Round 11/DivBProblem Setter: Ngô Minh Đức

2019-07-31 09:13:54
code 1 dòng AC
2019-07-10 08:51:54
code 3 dòng là xong
2019-04-30 17:36:58
3 dòng là xong

Last edit: 2019-07-11 07:15:09
2018-03-17 09:04:07
2017-08-20 20:33:15 Ðặng Minh Tiến
https://kienthuc24h.com/ant-spoj-kien/
2017-02-14 10:28:25
thuật toán hoán vị Josephus
2017-01-18 08:02:10 Nguyễn Vĩnh Thịnh
đù hôm thầy cho làm lại ko làm đc ^^ hóa ra ez vcl
2016-09-24 15:44:42
Code:
http://shink.in/wO1ks
2016-07-04 10:21:39
Có 5 dòng AC mà ns 10 dòng. Toàn Sửu Nhi k hà.
2016-05-01 15:42:12
AC với 87 kí tự =)))))))