8504: The Lucky Game

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:2 解决:2

题目描述

John and Brus believe that the digits 4 and 7 are lucky and all others are not. According to them, a lucky number is a number that contains only lucky digits in its decimal representation.

John and Brus play the following game. Initially, there is an interval of integers between a and b, inclusive. Then, John choose a subinterval of the initial interval that contains exactly jLen numbers. Finally, Brus chooses a subinterval of John's subinterval that contains exactly bLen numbers. The outcome of the game is the total number of lucky numbers in Brus's subinterval.

John follows the optimal strategy that maximizes the outcome. Brus follows the optimal strategy that minimizes the outcome. Return the outcome of the game.

输入

Each line contains four integers a,b,jLen,bLen.

1<=a<=b<=4747

1<=jLen<=b-a+1

1<=bLen<=jLen

输出

For each line of input,print the outcome of the game.

样例输入 复制

1 10 2 1
4 8 3 2

样例输出 复制

0
1