This page is still under construction.

Parts of this page are still being built. What you see may change.

Circle

Time limit1sMemory limit128 MB

Summary
Given grid side k and circle radius r centered at a grid vertex, count cells the circle passes through, excluding cells touched only at a corner.
Level

Hard8 of 10

Topics
Math, Geometry, Number theory, Binary search
Solved
No attempts yet

Problem

There is an infinitely large sheet of grid paper made up of square cells. Each cell has a side length of kk units.

A circle of radius rr units is drawn on this sheet. The center of the circle lies at the intersection of two grid lines, that is, at the vertex where four cells meet.

Every cell that the circle passes through (every cell that contains a part of the circle) is painted. However, if the circle only touches a single corner of a cell (meeting the cell at that corner alone), that cell is not painted.

Given the natural numbers kk and rr, write a program that computes the number of painted cells.

Input

The first line contains two natural numbers kk and rr, separated by a space. (k<30000k < 30000, r<30000r < 30000)

Output

Print the number of painted cells on a single line.

Examples2

  1. Example 1

    Input
    1 5
    
    Expected output
    28
    
  2. Example 2

    Input
    3 7
    
    Expected output
    20