The longest sequence P69932


Statement
 

pdf   zip

html

You are given several natural numbers. Put some of the numbers side by side according to these rules:

  • the resulting sequence must be increasing;
  • there cannot be two even numbers together nor two odd numbers together.

Write a program such that, for every given line, prints the length of the longest sequence that can be produced according to the rules above using the numbers on that line.

Input

Input consists of several lines. Each line contains a sequence of natural numbers.

Output

For each line of the input, print a line with the length of the longest sequence that can be made according to the rules given above.

Public test cases
  • Input

    1 2 3 4 5 6 7
    8 8 8 5 5 3
    1000000
    
    0 12 56 5 5 34 78 0 17 15 56
    

    Output

    7
    2
    1
    0
    5
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C++ Python