Words between two words P12061


Statement
 

pdf   zip

thehtml

Write a program that, given a sequence of words, prints the number of words between the word “beginning” and the word “end”. If the word “beginning”, the word “end” or both words are missing, or if they appear in inverse order, tell so.

Input

Input consists of several words. The words “beginning” and “end” appear, at most, once.

Output

Print the number of words between the word “beginning” and the word “end”, if these appear in this order. Otherwise, print “wrong sequence”.

Public test cases
  • Input

    hi how are you beginning we are inside yes we are inside end bye
    

    Output

    7
    
  • Input

    hello beginning bye
    

    Output

    wrong sequence
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python