Under construction

Still being built. Things may change

Immersion into the Animus

Time limit2sMemory limit1024 MB

Summary
Given n and k, count the unordered pairs of distinct natural numbers, each at most n, that sum to k.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

The Animus is a complex machine that reads a person's genetic memory and projects it in 3D.

For simplicity, assume that every cell in the body and every event has a unique code, a natural number. The algorithm that computes these codes belongs to Abstergo Industries and is not disclosed. Cell codes are numbered consecutively.

To read the information of an event with code kk, the Animus searches for all pairs of cells whose codes do not exceed nn and whose codes sum to kk. For example, when reading event 33 with n=5n = 5, there is exactly one suitable pair, the cells with codes 11 and 22. If n=3n = 3 and k=2k = 2, no pair exists, because cell codes do not repeat.

Before Dr. Sofia Rikin immerses Callum Lynch into Spain in 1492, she wants to know how many pairs of cells the Animus will find. The Animus has no function for counting this, so given nn and kk, count the pairs of distinct natural numbers that do not exceed nn and sum to kk.

Input

The first line contains two natural numbers nn and kk: the upper limit on a cell code and the sum of the codes of the pairs to find, respectively (1≤n,k≤10151 \le n, k \le 10^{15}).

Output

Print one line with the number of pairs of distinct natural numbers that do not exceed nn and sum to kk.

Hint

For working with numbers greater than 10910^9, a 64-bit integer type is recommended.

Examples3

  1. Example 1

    Input
    5 3
    
    Expected output
    1
    
  2. Example 2

    Input
    6 11
    
    Expected output
    1
    
  3. Example 3

    Input
    1 1
    
    Expected output
    0