PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CCBCHBON0000044. Đếm chữ số trong luồng ký tự (Count Digits in the Entire Stream)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm chữ số trong luồng ký tự (Count Digits in the Entire Stream)

Count Digits in the Entire Stream

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Read the complete ASCII stream to EOF and count bytes representing digits 0..9. Ignore spaces, tabs, newlines and other symbols. A period does not terminate this task.

Input

An ASCII byte stream of 0..1000000 bytes (PHOJ-specific cap); it may be empty or not LF-terminated.

Output

Print the digit count followed by LF.

Subtasks

  • Subtask 1 (20%): ASCII stream length 0..100 bytes.

  • Subtask 2 (30%): ASCII stream length 0..4000 bytes.

  • Subtask 3 (50%): ASCII stream length 0..1000000 bytes.

Examples

Example 1

Input:

A1 2B3

Output:

3

Explanation:

Each digit byte contributes one; a period does not stop reading. Exact input: "A1 2B3"; exact output: "3\n".

Example 2

Input:


	

Output:

0

Explanation:

Each digit byte contributes one; a period does not stop reading. Exact input: "\n\t"; exact output: "0\n".

Example 3

Input:

0.12
3

Output:

4

Explanation:

Each digit byte contributes one; a period does not stop reading. Exact input: "0.12\n3"; exact output: "4\n".

Note on displayed bytes: \n denotes an actual LF, \t an actual tab and \r an actual CR. The JSON-style Input renderings in explanations are diagnostic only, not extra input characters.