The invention relates to compounds of formula where hetaryl I, hetaryl II, R1, R2, R3, R4, m, n, and o are as defined in the specification or to pharmaceutically active acid addition salts thereof. The compounds of formula I are modulators for amyloid beta and thus may be useful for the treatment or prevention of a disease associated with the deposition of beta-amyloid in the brain, in particular Alzheimer's disease, and other diseases such as cerebral amyloid angiopathy, hereditary cerebral hemorrhage with amyloidosis, Dutch-type (HCHWA-D), multi-infarct dementia, dementia pugilistica and Down syndrome.