input: from typing import List
  
  def find_longest_valid_subsequence_length(nums: List[int]) -> int:
      """
      Given a list of integers nums, write a function to find the maximum length of a subsequence
      that satisfies the following condition: for any consecutive elements (sub[i], sub[i+1]), 
      the sum of sub[i] and sub[i+1] has the same parity.
  
      Return the length of the longest subsequence that meets the criteria.
  
      A subsequence is an array that can be derived from another array by deleting some or no elements 
      without changing the order of the remaining elements.
  
      Examples:
      >>> nums = [1,2,3,4]
      4
      >>> nums = [1,2,1,1,2,1,2]
      6
  
      Constraints:
      2 <= len(nums) <= 200000
      1 <= nums[i] <= 10000000
      """
output:     
      if not nums:
          return 0
  
      odd_count = 0
      even_count = 0
  
      for num in nums:
          if num % 2 == 0:
              even_count += 1
          else:
              odd_count += 1
  
      return odd_count + even_count - (0 if min(odd_count, even_count) == 0 else 1)
  