A substituted amide compound is useful as an active ingredient of a pharmaceutical composition, in particular a pharmaceutical composition for treating diseases caused by lysophosphatidic acid (LPA). The compound is of a formula:In this formula, A is an optionally substituted aryl, etc.; B is an optionally substituted 5-membered aromatic hetero ring group; X is a single bond or —(CRX1RX2)n—; n is 1, 2, 3, or 4; RX1 and RX2 are hydrogen, etc.; Y1 to Y5 are each CRY or N; each RY is hydrogen, etc.; R1 and R2 are hydrogen, etc.; m is 1, 2, or 3; R3 is hydrogen, etc.; and R4 is an optionally substituted lower alkyl, etc.