#include <bits/stdc++.h>
using namespace std;
main(){
int n,x,y;
while (cin>>n,n!=0){
int x=1;
for(int i=2;i<=sqrt(n);++i){
if(n%i==0 && i!=sqrt(n)) {x+=i; x+=n/i;}
else if(n%i==0 && i==sqrt(n)) x+=i;
}
int y=1;
for(int i=2;i<=sqrt(x);++i){
if(x%i==0 && i!=sqrt(x)) {y+=i; y+=x/i;}
else if(x%i==0 && i==sqrt(x)) y+=i;
}
if(x==n) cout<<"="<<n<<endl;
else if(y==n) cout<<x<<endl;
else cout<<"0"<<endl;
}
}