Skip to main content
Back to problems
Codeforces
Easy
Arrays
Math
Bear and Raspberry

Find how much the first bear must eat to become strictly heavier than the second bear.

Acceptance 0%
Problem Statement

Problem

Two bears have weights aa and bb. The first bear wants to be strictly heavier than the second bear. Each year, the first bear gains weight by multiplying its weight by 3, while the second bear gains weight by multiplying its weight by 2.

Your task is to determine the minimum number of years after which the first bear's weight becomes strictly greater than the second bear's weight.

Notes

  • In each year, both bears grow simultaneously.
  • You only need to output the smallest non-negative integer nn such that a3n>b2na \cdot 3^n > b \cdot 2^n.

Input Format

  • The first and only line contains two integers aa and bb.

Output Format

  • Print one integer: the minimum number of years needed for the first bear to become strictly heavier than the second bear.

Constraints

  • 1a,b1091 \le a, b \le 10^9
  • The answer fits in a standard integer type.
Examples
Sample cases returned by the problem API.

Example 1

Input

4 7

Output

2

Explanation

After 1 year: 43=124\cdot 3=12 and 72=147\cdot 2=14, so the first bear is still lighter. After 2 years: 123=3612\cdot 3=36 and 142=2814\cdot 2=28, so the first bear becomes heavier.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.