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

#CT0000075. Mật khẩu an toàn (Secure Passwords)

Bài tập này chưa được xếp vào lộ trình.

Mật khẩu an toàn (Secure Passwords)

Secure Passwords

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a string SS consisting only of English letters (A–Z, a–z) and digits (0–9).

A password is a contiguous substring of SS. It is secure if all the following requirements hold:

  • It contains at least 88 characters.
  • It contains at least one uppercase English letter.
  • It contains at least one lowercase English letter.
  • It contains at least one digit.

Substrings with different starting or ending positions are counted separately, even if their contents are identical.

Count the total number of contiguous substrings that are secure passwords.

Input

One line containing the string SS.

Output

Output one integer: the number of secure passwords.

Subtasks

  • Subtask 1 (30 points): 1≤∣S∣≤1501 \le |S| \le 150; every character belongs to A–Z, a–z, or 0–9.
  • Subtask 2 (30 points): 1≤∣S∣≤40001 \le |S| \le 4000; every character belongs to A–Z, a–z, or 0–9.
  • Subtask 3 (40 points): 1≤∣S∣≤2⋅1051 \le |S| \le 2\cdot10^5; every character belongs to A–Z, a–z, or 0–9.

Examples

Example 1

Input

ABC123abc

Output

3

Explanation: The string has 9 characters. Both length-8 substrings ABC123ab and BC123abc include uppercase, lowercase, and a digit; the length-9 substring also qualifies. Shorter substrings do not.

Example 2

Input

aaaBBB111

Output

3

Explanation: The two length-8 substrings aaaBBB11 and aaBBB111, and the full length-9 string, satisfy all three character requirements.

Example 3

Input

Abcdef12

Output

1

Explanation: The entire string has length 8 and contains A, lowercase letters, and digits 1, 2. Only the whole string is long enough.