package 每日一题;

import java.util.Scanner;

public class NC15173 {
    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int shuru = sc.nextInt();
        System.out.println(diguishuchu(shuru));
    }
    public static int anweiqiuhe(int n){
        int ans = 0;
        while (n!=0) {
            ans += n%10;
            n = n/10;
        }
        return ans;
    }
    public static int diguishuchu(int n){
        if(anweiqiuhe(n)>9) return anweiqiuhe(anweiqiuhe(n));
        else return anweiqiuhe(n);
    }
}

有个测试点没过,有点奇怪。