/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main(String[] args) {
	    int n = 10000;
	    int sum = -1;
		for (int i = 1; i <= n; i *= 2) {
		    for (int j = 1; j <= n; j *= 3) {
		        for (int k = 1; k <= n; k *= 5) {
		            int x = i*j*k;
		            if (x <= n) {
		                sum += x;
		            } else {
		                break;
		            }
		        }
		    }    
		}
		System.out.println("sum(constructive)=" + sum);
		
		sum = 0;
		List<Integer> otherPrimes = new ArrayList<>();
		for (int i = 2; i <= n; i++) {
		    boolean isDivisibleByOtherPrimes = false;
		    for (int p : otherPrimes) {
		        if (i % p == 0) {
		            isDivisibleByOtherPrimes = true;
		            break;
		        }
		    }
		    if (!isDivisibleByOtherPrimes) {
		        if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0) {
		            sum += i;
		        } else {
		            otherPrimes.add(i);
		        }
		    }
		}
		System.out.println("sum(DP)=" + sum);
	}
}