The fill bucket is a tool available in many drawing tools which replaces a contiguous chunk of one color with a another color.
We are going to define a fill bucket which operates on lists of non-negative integers. When used this replaces a contiguous sub-list of one integer with another selected integer. For example
[0,1,2,0,0,2,2,2,3,3,3,0,1]
[0,1,2,0,0,1,1,1,3,3,3,0,1]
Here we replaced 3 consecutive 2s with 1s.
The question is if we want to blank an entire list, making all of its elements 0, how many times do we have to use the fill bucket.
For example the list
[1,2,1,2,1,2,1,2,1]
can be blanked with 5 uses of the bucket:
121212121
111212121
111112121
111111121
111111111
000000000
and no fewer.
Your task is to take a list of non-negative integers and output the number of buckets required to blank it.
This is code-golf so answers will be scored in bytes with fewer bytes being the goal.
Test cases
[] -> 0
[0,0] -> 0
[1,1,1,1,1] -> 1
[0,2,0,2,0,2,0,2,0] -> 4
[1,2,1,2,1,2,1,2,1] -> 5
[1,2,3,4,5,4,3,2,1] -> 5