All problems

Problem 850

Count Odd Numbers in an Interval

Easy · 10 pts · Math

Problem

Count the odd integers between LOW and HIGH, both included. A loop over the range would be far too slow for ranges of size 10^9. The number of odd integers from 1 to X is (X + 1) / 2 rounded down, so the answer is that count for HIGH minus the count for LOW - 1. Work out a few small examples to convince yourself.

Input

A single line with two integers LOW and HIGH.

Output

Print the number of odd integers in [LOW, HIGH].

Constraints

0 <= LOW <= HIGH <= 10^9

Example input

3 7

Example output

3

Explanation

Between 3 and 7 the odd numbers are 3, 5 and 7, so the answer is 3. The formula gives (7 + 1) / 2 - (2 + 1) / 2 = 4 - 1 = 3.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Arranging Coins Next: Number of Steps to Reduce a Number to Zero