Computer Science, asked by kothamasuhemanth85, 1 year ago

We are all familiar with alpha numeric keypad that was used for messaging in earlier days. Given sequence of numbers 2-9 (both inclusive), find out the number of distinct alphabets that can be formed.

The rules of interpreting keypad strokes are as follows

1) Let’'s understand with example. 25 can mean AJ but it can also mean pressing button 5 two times. In that case it becomes K. See Examples section for better understanding.

2) Maximum number of distinct alphabets that can be formed cannot exceed 26

3) Alphanumeric keyboard used is as follows

· key 2 has letters "A B C"

· key 3 has letters "D E F"

· key 4 has letters "G H I"

· key 5 has letters "J K L"

· key 6 has letters "M N O"

· key 7 has letters "P Q R S"

· key 8 has letters "T U V"

· key 9 has letters "W X Y Z"

4) Input does not contain either 1 or 0 because no keypad buttons are associated with these numbers.

Constraints
1 <= Length of Input Literals <= 40

Input Format
Single Line contains a number with literals [2-9]

Output
Number of distinct alphabets after factoring all possible interpretations of the input


Explanation
Example 1

Input

253

Output

5

Explanation

It can be interpreted as AJD, KD , AE, thus distinct alphabets formed- A , J , D ,K , E = 5 distinct alphabets.

Example 2

Input

294

Output

5

Answers

Answered by Sidyandex
1

Solution: out of the 8 digits, number of digits selected can be written as 8C3 = 56 ways, similarly, 2 out of 5 alphabets = 5C2= 10 ways and 3 digits and 2 alphabets can be arranged as 5! = 120 ways.

Therefore, overall combination of the alphanumeric codes = 56 x 10 x 120 = 67200.

Similar questions