Numerical Intervals#1692

Numerical Intervals

1 second
64 megabytes
Easy

Today at school, Vasya learned about numerical intervals. Each interval is defined by a pair of numbers—its start and end—and specifies whether each endpoint is included. There are four types of intervals:

For homework, Vasya needs to count the number of integers within each given interval. Since they haven't covered real numbers yet, and are expressed as rational numbers: x = a/b, y = c/d ( and are integers, and are positive integers).

Consider the example: [3/2, 4). Here, d = 1, so instead of , it is simply written as . This interval contains two integers: and ; the number is not included.

Help Vasya with his homework by writing a program that calculates the number of integers within a given numerical interval.

Input

The input starts with an opening square or round bracket. Next is the number in the format or , where |a| \leq 10^9, 0 < b \leq 10^9. This is followed by a comma and a space. Then, the number in the same format. Finally, a closing square or round bracket. The input ends with a newline.

It is guaranteed that the given numerical interval is not empty (i.e., it contains at least one number, not necessarily an integer).

Output

For the given numerical interval, output a single number: the count of integers within it.

Examples

Example 1

Loading
Loading