#include <bits/stdc++.h>
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector <int> d(n), c(m);
    rep (i, n) cin >> d[i];
    rep (i, m) cin >> c[i];

    const int INF = 1000000000;
    vector <vector <int>> dp(m + 2, vector <int> (n + 1, INF));

    dp[0][0] = 0;
    rep (i, m + 1) rep (j, n) if (dp[i][j] != INF) {
        dp[i + 1][j]     = min(dp[i + 1][j],     dp[i][j]);
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + d[j] * c[i]);
    }

    int ans = INF;
    rep (i, m + 1) ans = min(ans, dp[i][n]);
    cout << ans << endl;

    return 0;
}
