#C4873. Balance Check of Alphanumeric Characters
Balance Check of Alphanumeric Characters
Balance Check of Alphanumeric Characters
Given an alphanumeric string, determine whether the number of letters is equal to the number of digits. If they are equal, output 1
; otherwise, output 0
. The solution should read the input from stdin and write the result to stdout.
The problem can be mathematically expressed as: \( |\{ c \in s : c \text{ is a letter} \}| = |\{ c \in s : c \text{ is a digit} \}| \). If this equality holds, print 1; otherwise, print 0.
Note that the input string may include an empty string. By convention, since both letter and digit counts are 0 for an empty string, they are considered equal, so the output should be 1.
inputFormat
The input consists of a single line containing a string s
comprised of alphanumeric characters (letters and digits).
outputFormat
Output a single integer: 1
if the number of letters equals the number of digits, and 0
otherwise.
a1b2
1