import java.util.Scanner;
import java.util.regex.Pattern;
public class Test03 {
public static void main(String[] args) {
while (true){
String str = new Scanner(System.in).nextLine();
if(isInteger(str)){
if(isPrime(Integer.valueOf(str))){
System.out.println(str);
}else{
int sum=0;
for (int i = 0; i sum+=str.charAt(i)-48;
}
System.out.println(sum);
}
break;
}
}
}
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
}
private static boolean isPrime(int a) {
if(a==1)return false;
if(a==2)return true;
int m= (int) (Math.sqrt(a)+1);
for (int i = 2; i <= m; i++) { //最小的素数是2
if (a % i == 0) { //除了1和本身之后没有约数即为素数
return false;
}
}
return true;
}
}