I am looking for a way to get number of sentinel-2 images per pixel over a period, which are not affected by cloud.

So, the procedure would be first masking cloudy pixels of a Sentinel-2 stack (for instance using SLC band), then generating daily composites per day (aggregate_temporal_period(“day”,reducer=“median”)). Now, we should have a Sentinel-2 stack of non-cloudy pixels. Finally, counting the number of non-cloudy images per pixel from the stack using sum function.

Just as an example, if there are 8 observations (non-cloud) for pixel #1 from different days in 2 months, then the number of clear sky observation is 8 for this pixel. And in the same stack, if 3 of the observations are cloudy for pixel #2 , the value is 5 for pixel #2.

Mohammad