The Dice

3.9

83 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

There are x  number of girls and they rolled a dice in turns one after another.

If the number on the dice is 6, then the dice will be rolled again until she get a number other than 6.

Since you know the sequence of numbers which the dice shows when rolled each time, you have to find what is the total number of girls or if the sequence is invalid.

Input format

A single line that contains a string s (1|s|105) denoting the sequence of numbers the dice rolls on written as string.

Output format

  • If the sequence is valid print the number of girls  
  • If the sequence is invalid print 1
Time Limit: 2
Memory Limit: 256
Source Limit:
Explanation

The second person rolls the dice 3 times so the number of people will be 5.

Editor Image

?