This is the formula for the surface area of a cylinder including the ends, like the total surface area of a can of peas.
S = 2·π·r² + 2·π·r · H
Divide each side by 2·π·r :
S/2·π·r = r + H
Subtract r from each side :
H = (S/2·π·r) - r
or
H = (S - 2·π·r²) / (2·π·r)