We study the following problem: party A's secret input is a, party B's secret input is b, and party C's input is empty; they want to know if a = b with restriction that A and B should not learn anything more than what is implied by their secret inputs and the comparison result, and C should not learn anything about a or b except if a = b. This problem can be seen as a variant of the socialist millionaires' problem. We propose a simple and efficient protocol for this problem from a semantically homomorphic encryption scheme. The protocol is fair if party C is semi-honest.