AlgoUniversity
  • Go Back
Discussion
Winning Ticket Number :

Author

Shikhar Mehrotra

Difficulty Level : Easy

Submissions : 824

Asked In : Cogoport

Marks :10

: 28 | : 0

Harry wants to sell lottery tickets and earn money out of it . In his basic research that most lottery tickets follow some logic in deciding the winning ticket number. He studies many algorithms for the same and finally decided in to device algorithm.

Every day he provides 2 numbers as an input to the algorithm which is $$$N$$$, $$$K$$$ where $$$N$$$ is number of primes to be used in algorithm and $$$K$$$ is a single digit odd number.

Algorithm WinningTicket Number($$$N$$$,$$$K$$$):

Step 1 . Create a list L of first N prime number that end with digit K and include 2 and 5 in that list.

Step 2. Find the sum of all numbers of $$$L$$$ and denote its sum as $$$S$$$.

Step 3. Print the sum S as the winning ticket number for that day.

Input

The first line of input contains integers separated by space $$$N$$$ and $$$K$$$.

$$$1< N < 1000$$$

$$$K$$$ can take values $$${1,3,7,9}$$$

Output

A single line of output consisting of sum S which is the winning ticket number for that day.

Examples

Input
5 7
Output
182
Input
10 3
Output
677

Note

In first test case list will be $$${2,5,7,17,37,47,67}$$$ which when added results in $$$182$$$.

In second test case list will be $$${2,5,3,13,23,43,53,73,83,103,113,163}$$$ which when added results in $$$677$$$.

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.