#import <Foundation/Foundation.h>

NS_INLINE long get_sum(int n){
    int v=0;
    while(n){
        v+=n%10;
        n/=10;
    }
    return v;
}

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *s = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSInteger N = [s integerValue];

        long v=1e9;
        for(int i=1;i<=N-1;i++){
            v=MIN(v,get_sum(i)+get_sum(N-i));
        }
        NSString *answer = [NSString stringWithFormat:@"%ld",v];
        
        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];
        [fileHandle writeData:[answer dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        [fileHandle closeFile];
    }
    return 0;
}
