A. Algorithm Memories

    传统题 1000ms 256MiB

Algorithm Memories

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

To perform better in the competition, you need to unlock your algorithm memories.

However, your memories are locked behind a password — a string of exactly 55 lowercase letters.

You have tried a guess password, and the system returned a response string consisting of digits 0\texttt{0}, 1\texttt{1} or 2\texttt{2}:

  • 0\texttt{0} means the letter does not appear in the correct password.
  • 1\texttt{1} means the letter exists in the correct password but not at this position.
  • 2\texttt{2} means the letter is correct and in the correct position.

Your task is to determine how many possible passwords are consistent with the guess and the response.

Format

Input

The first line contains a string with 55 lowercase letters, the password you guessed.

The second line contains a string with 55 digits, the response.

Output

One integer, the number of possible passwords.

Samples

maidx
20212
24

Hello ACM 2025 环境测试

未参加
状态
已结束
规则
ACM/ICPC
题目
2
开始于
2025-8-12 13:00
结束于
2025-8-12 18:00
持续时间
5 小时
主持人
参赛人数
21