#include <bits/stdc++.h>
using namespace std;
vector<int> prime;
char sieve[1000005];
void primeSieve() {
  sieve[0] = 1, sieve[1] = 1;
  prime.push_back(2);
  for (int i = 4; i <= 1000005; i += 2) sieve[i] = 1;
  int sqrtn = sqrt(1000005);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (sieve[i] == 0) {
      for (int j = i * i; j <= 1000005; j += 2 * i) sieve[j] = 1;
    }
  }
  for (int i = 3; i <= 1000005; i += 2)
    if (sieve[i] == 0) prime.push_back(i);
}
bool isPrime(int n) {
  if (n == 1) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
vector<int> divisor;
int SOD(int n) {
  int sqrtn = sqrt(n);
  int res = 0;
  for (int i = 1; i < sqrtn; i++) {
    if (n % i == 0) {
      res += i;
      res += n / i;
      divisor.push_back(i);
      divisor.push_back(n / i);
    }
  }
  if (n % sqrtn == 0) {
    if (sqrtn * sqrtn == n) {
      res += sqrtn;
      divisor.push_back(sqrtn);
    } else {
      res += sqrtn;
      res += n / sqrtn;
      divisor.push_back(sqrtn);
      divisor.push_back(n / sqrtn);
    }
  }
  return res;
}
int main() {
  long long n, r, h, m, p = 1, q, k, kauntt = 0, a, b, talc, flag = 0, calc,
                        c0 = 0, c1 = 0, c2 = 0, minn, temp = 0, div, sum = 0;
  vector<long long> v, v1;
  cin >> n;
  SOD(n);
  sort(divisor.begin(), divisor.end(), greater<int>());
  k = 0;
  for (int i = 0; i < divisor.size() - 1; i++) {
    if (isPrime(divisor[i])) {
      sum += divisor[i] + 1;
      break;
    }
    if (divisor[k] % divisor[i + 1] == 0) {
      sum += divisor[k];
      k = i + 1;
    }
  }
  cout << sum << endl;
  return 0;
}
