ㄧㄣyīnㄏㄨㄛˋhuòㄉㄜˊㄈㄨˊ

  1. 遭遇災禍原因反而得到好處醒世恆言··生死夫妻》:乃是義夫節婦一片心腸感動天地所以不死因禍得福。」因禍為福」。塞翁失馬

to profit from a disaster (idiom)​; some good comes out of a setback, It's an ill wind that blows nobody any good.