#include <iostream>

using namespace std;

int number1;
int number2;
int sum;

int CountDivisors(int a)
{
    int sum = 0;
    for(int i=1; i<a; i++)
    {
        if((a%i)==0)
            sum+=i;
    }
    return sum;
}

int main()
{
    while(number1<10000)
    {
        number2 = CountDivisors(number1);

        if(number2<10000)
            if(number1==CountDivisors(number2) && (number1 != number2))
                sum+=number1;

        number1++;
    }

    cout << sum << endl;
    return 0;
}