ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

ICPC UrFU Contest Qualifier 2026

About     Problems     Submit solution     Judge status     Standings
Contest is over

J. UwU-Equation

Time limit: 1.0 second
Memory limit: 256 MB
Kitani likes finding beauty in mathematics, especially in number theory. During the search, the following interesting equation was found:
φ(n) + U · ω(U · n) = M,
where U and M — are given positive integers.
Here, φ(n) — is Euler’s totient function: the number of integers from 1 to n that are coprime with n, that is, their greatest common divisor with n is 1. For example, φ(10) = 4 — these numbers are 1, 3, 7, 9.
ω(n) — is the number of different prime divisors of n. For example, ω(60) = 3 — these numbers are 2, 3, 5.
Now Kitani is interested in how many solutions in positive integers this equation has. After a long search, there is almost no time left, so now this task is passed to you.

Input

The only line contains integers U and M (1 ≤ U, M ≤ 105).

Output

Print one integer — the number of solutions of the equation in positive integers.

Samples

inputoutput
1 1
1
19 84
2

Notes

The solution in the first example:
  • φ(1) + 1 · ω(1 · 1) = 1 + 1 · 0 = 1
The solutions in the second example:
  • φ(30) + 19 · ω(19 · 30) = 8 + 19 · 4 = 84
  • φ(47) + 19 · ω(19 · 47) = 46 + 19 · 2 = 84
Problem Author: Nikita Sobolev
Problem Source: The 2026 ICPC UrFU Qualification
To submit the solution for this problem go to the Problem set: 2240. UwU-Equation