Under construction

Still being built. Things may change

SSR

Time limit2sMemory limit512 MB

Summary
Count ordered pairs (A, B) with A <= N and B <= M for which (sqrt(A) + sqrt(B))^2 is an integer.
Level

Medium7 of 10

Topics
Number theory, Math, Combinatorics, Implementation
Solved
No attempts yet

Problem

For two positive integers AA and BB, define SSR(A,B)=(A+B)2\mathrm{SSR}(A, B) = (\sqrt{A} + \sqrt{B})^2.

Given two integers NN and MM, write a program that counts the ordered pairs (A,B)(A, B) with 1≤A≤N1 \le A \le N and 1≤B≤M1 \le B \le M for which SSR(A,B)\mathrm{SSR}(A, B) is an integer.

Input

The first line contains NN and MM, separated by a space. (1≤N,M≤777771 \le N, M \le 77777)

Output

Print the number of ordered pairs (A,B)(A, B) that satisfy the condition on the first line.

Examples3

  1. Example 1

    Input
    2 2
    
    Expected output
    2
    
  2. Example 2

    Input
    10 1
    
    Expected output
    3
    
  3. Example 3

    Input
    3 8
    
    Expected output
    5