#include <iostream>
#include <cmath>
using namespace std;
int sum_dividers(int n){
int sum=0;
for(int i=1; i<sqrt(n); i++){
if((n%i)==0)sum+=i+(n/i);
}
int i=sqrt(n);
if(i*i==n)sum+=i;
return sum;
}
int main() {
int n;
cin>>n;
int max_sum=0;
int max_number=0;
int j;
for(j=1; j<=n; j++){
int s=sum_dividers(j);
if(max_sum<s){
max_sum=s;
max_number=j;
}
}
cout<<max_number<<" "<<max_sum;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IHN1bV9kaXZpZGVycyhpbnQgbil7CiAgICBpbnQgc3VtPTA7CiAgICBmb3IoaW50IGk9MTsgaTxzcXJ0KG4pOyBpKyspewogICAgICAgIGlmKChuJWkpPT0wKXN1bSs9aSsobi9pKTsKICAgIH0KICAgIGludCBpPXNxcnQobik7CiAgICBpZihpKmk9PW4pc3VtKz1pOwogICAgcmV0dXJuIHN1bTsKfQogCmludCBtYWluKCkgewogICAgaW50IG47CiAgICBjaW4+Pm47CiAgICBpbnQgbWF4X3N1bT0wOwogICAgaW50IG1heF9udW1iZXI9MDsKICAgIGludCBqOwogICAgZm9yKGo9MTsgajw9bjsgaisrKXsKICAgIAlpbnQgcz1zdW1fZGl2aWRlcnMoaik7CiAgICAgICAgaWYobWF4X3N1bTxzKXsKICAgICAgICAgICAgbWF4X3N1bT1zOwogICAgICAgICAgICBtYXhfbnVtYmVyPWo7CiAgICAgICAgfQogICAgfQogICAgY291dDw8bWF4X251bWJlcjw8IiAiPDxtYXhfc3VtOwogICAgcmV0dXJuIDA7Cn0=