#include <bits/stdc++.h>

using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) reep((i),0,(n))

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	vector<int> w(m);
	rep(i, m) cin >> w[i];
	vector<int> ans(n,1e9);
	rep(i,m){
		for(int j=n-1;j>=0;j--){
			if(j) ans[j] = min(ans[j],ans[j-1]+v[j]*w[i]);
			else ans[j] = min(ans[j],v[j]*w[i]);
		}
	}
	cout<<ans[n-1]<<endl;
}