The present invention relates to a compound which has a glucokinase-activating effect and is useful as a therapeutic agent for diabetes mellitus, being represented by a formula (I):[wherein X1 represents a nitrogen atom, sulfur atom, oxygen atom or the like; R1 represents a 6- to 10-membered aryl group, 5- to 7-membered heteroaryl group or the like; D represents an oxygen atom or sulfur atom; R2 and R3 are the same or different, each representing a hydrogen atom, lower alkyl group or the like; a formula (II)represents an optionally substituted 5- to 7-membered heteroaryl group or the like; a formula (III)represents a monocyclic or bicyclic heteroaryl group] or a pharmaceutically acceptable salt thereof.