Circular Dance

Time limit2sMemory limit128 MB

Summary
Given N people in a circle, compute the minimum adjacent swaps needed to reverse their order up to rotation, which reduces to a closed-form floor formula.
Level

Medium4 of 10

Topics
Math, Combinatorics
Solved
No attempts yet

Problem

N people stand in a circle, holding hands in the order 1, 2, ..., N. In one swap, only two people who are currently adjacent in the circle may exchange places, and the people remain arranged in a circle after the swap.

The goal is to make the circular order exactly opposite to the initial order. Because the arrangement is circular, rotations of the same order are considered identical.

Find the minimum number of swaps needed to reverse the order.

Input

The first line contains the number of people N (1 ≤ N ≤ 32767).

Output

Print the minimum number of swaps needed to reverse the order.

Examples3

  1. Example 1

    Input
    6
    
    Expected output
    6
    
  2. Example 2

    Input
    5
    
    Expected output
    4
    
  3. Example 3

    Input
    4
    
    Expected output
    2