This page is still under construction.

Parts of this page are still being built. What you see may change.

Double Password

Interview

Time limit1sMemory limit1024 MB

Summary
Given two four-digit passwords, count how many four-digit sequences match at least one password in every digit position.
Level

Easy2 of 10

Topics
Math, Combinatorics, Implementation, Brute force
Solved
No attempts yet

Problem

A computer at ICPC headquarters is protected by a four-digit password. To log in, you normally need to guess the four digits exactly. However, the programmer who implemented the password check left a backdoor in the computer: there is a second four-digit password. If the programmer enters a four-digit sequence, and for each digit position the digit entered matches at least one of the two passwords in that same position, then that four-digit sequence will log the programmer into the computer.

Given the two passwords, count the number of distinct four-digit sequences that can be entered to log into the computer.

Input

The input consists of exactly two lines. Each of the two lines contains a string ss (∣s∣=4|s| = 4, s∈s \in {0-9}*). These are the two passwords.

Output

Output a single integer, which is the number of distinct four-digit sequences that will log the programmer into the system.

Examples2

  1. Example 1

    Input
    1111
    1234
    
    Expected output
    8
    
  2. Example 2

    Input
    2718
    2718
    
    Expected output
    1