Numbers
InterviewTime limit1sMemory limit1024 MB
Given three distinct digits and one of their six permutations, find that number's 1-based rank when all six permutations are sorted ascending.
- Level
Easy2 of 10
- Topics
- Math, Sorting, Implementation, Combinatorics
- Solved
- No attempts yet
Problem
Jurgita studies digits and numbers. She picked three distinct digits from to , formed every possible three-digit number using them, and sorted these numbers in increasing order. Because the three digits are all different, there are exactly distinct three-digit numbers.
You are given a three-digit number built from the chosen digits. Determine the position of in the sequence sorted in increasing order.
Input
The first line contains the three digits , , chosen by Jurgita, separated by spaces. The second line contains the number formed from the chosen digits.
Output
Print the position of the given number in the sequence.
Constraints
- ; ; ;