This page is still under construction.

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

Intersections

Time limit1sMemory limit512 MB

Summary
Count the intersection points of the piecewise triangular wave f(x) with the line g(x) = x/a, or report that there are infinitely many.
Level

Medium7 of 10

Topics
Math, Implementation, Brute force, Geometry
Solved
No attempts yet

Problem

You are given the following two functions. (N0\mathbb{N}_0 denotes the set of non-negative integers.)

f(x)={0,\mboxifx<0x−2k,\mboxif2k≤x<2k+1 (k∈N0)−x+2(k+1)\mboxif2k+1≤x<2k+2 (k∈N0)f(x)= \begin{cases} 0, & \mbox{if } x < 0 \\ x - 2k, & \mbox{if } 2k \le x < 2k+1 \, (k \in \mathbb{N}_0) \\ -x + 2(k+1) & \mbox{if } 2k + 1 \le x < 2k+2 \, (k \in \mathbb{N}_0) \end{cases}

g(x)=xag(x) = {x \over a}

How many points do the graphs of y=f(x)y=f(x) and y=g(x)y=g(x) have in common on the XY-plane?

Input

The first and only line of the input contains a single integer aa.

Output

Print the number of points where the graphs of y=f(x)y = f(x) and y=g(x)y = g(x) intersect. If there are infinitely many, print INF.

Constraints

  • ∣a∣≤109\left\vert a \right\vert \le 10^9; a≠0a \ne 0
  • aa is an integer.

Examples1

  1. Example 1

    Input
    2
    
    Expected output
    2