A - Large Digits Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 100

問題文

整数 n に対して、 n を十進法で表したときの各桁の和を S(n) で表すことにします。 例えば、S(123) = 1 + 2 + 3 = 6 です。

2 つの 3 桁の整数 A, B が与えられます。S(A)S(B) のうち大きい方の値を求めてください。

制約

  • 入力は全て整数
  • 100 \le A, B \le 999

入力

入力は以下の形式で標準入力から与えられる。

A B

出力

S(A)S(B) のうち大きい方の値を出力せよ。
S(A)S(B) が等しい場合は、S(A) を出力せよ。


入力例 1

123 234

出力例 1

9

S(123) = 1 + 2 + 3 = 6, \ S(234) = 2 + 3 + 4 = 9 なので、2 つのうち大きい方である 9 を出力します。


入力例 2

593 953

出力例 2

17

入力例 3

100 999

出力例 3

27

Score : 100 points

Problem Statement

For an integer n, let S(n) be the sum of digits in the decimal notation of n. For example, we have S(123) = 1 + 2 + 3 = 6.

Given two 3-digit integers A and B, find the greater of S(A) and S(B).

Constraints

  • All values in input are integers.
  • 100 \le A, B \le 999

Input

Input is given from Standard Input in the following format:

A B

Output

Print the value of the greater of S(A) and S(B).
If these are equal, print S(A).


Sample Input 1

123 234

Sample Output 1

9

We have S(123) = 1 + 2 + 3 = 6 and S(234) = 2 + 3 + 4 = 9, so we should print the greater of these: 9.


Sample Input 2

593 953

Sample Output 2

17

Sample Input 3

100 999

Sample Output 3

27