Dynamic Programming. Simple programs to determine min count based on a condition