PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000295. Frodo và những chiếc gối (Frodo and pillows)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Frodo và những chiếc gối (Frodo and pillows)

Frodo and pillows

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn beds in a row and mm pillows. Every bed receives at least one pillow, all pillows must be distributed, and adjacent beds may differ by at most one pillow. Frodo occupies bed kk (1-based). Maximize his pillow count.

Input

One line contains three integers n,m,kn,m,k.

Output

Print one integer: the maximum achievable value.

Subtasks

  • Subtask 1 (20 points): 1≤n≤m≤201\le n\le m\le20; 1≤k≤n1\le k\le n.
  • Subtask 2 (30 points): 1≤n≤m≤1091\le n\le m\le10^9; 1≤k≤n1\le k\le n; k∈{1,n}k\in\{1,n\}.
  • Subtask 3 (50 points): 1≤n≤m≤1091\le n\le m\le10^9; 1≤k≤n1\le k\le n.

Examples

Input 1

4 6 2

Output 1

2

Explanation

Allocation (2,2,1,1) works. Giving Frodo three requires at least eight pillows.

Input 2

3 10 3

Output 2

4

Explanation

Allocation (3,3,4) works. Five at bed 3 requires at least twelve.