Measurement of the branching fraction B(Bu+→J/ψπ+) and search for Bc+→J/ψπ+