PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000056. Charlie và các số nguyên tố (Charlie and Prime Numbers)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Charlie và các số nguyên tố (Charlie and Prime Numbers)

Charlie and Prime Numbers

Source: CodeChef

Version: Phuoc Hung OJ Extended

Problem Statement

Charlie chooses two positive integers MM and NN with M≤NM\le N. He wants the sum of all prime numbers in the inclusive interval [M,N][M,N]. A prime is an integer greater than 11 with exactly two positive divisors, 11 and itself. If the range contains no primes, the sum is 00.

Input

One line contains positive integers MM and NN.

Output

Print one integer: the sum of all primes from MM through NN, inclusive.

Subtasks

  • Subtask 1 (30 points): 1≤M≤N≤10001\le M\le N\le 1000.
  • Subtask 2 (30 points): 1≤M≤N≤1000001\le M\le N\le 100000.
  • Subtask 3 (40 points): 1≤M≤N≤50000001\le M\le N\le 5000000.

Examples

Input

2 10

Output

17

Explanation

The primes in [2,10][2,10] are 2,3,5,72,3,5,7; 4,6,8,9,104,6,8,9,10 are composite. Add them step by step: 2+3=52+3=5, then 5+5=105+5=10, then 10+7=1710+7=17. Therefore print 17.