#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<deque>
using namespace std;
namespace mine
{
typedef long long ll;
#define double long double
const int INF=0x3f3f3f3f;
ll ()
{
ll ans=0;char c=getchar();int f=1;
while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
return ans*f;
}
void write(ll num)
{
if(num<0) {num=-num;putchar('-');}
if(num>9) write(num/10);
< 大专栏 【bzoj3441】乌鸦喝水div class="line"> putchar('0'+num%10); }
void writeln(int num){write(num);puts("");}
#define FR first
#define SE second
#define MP make_pair
#define pr pair<ll,ll>
#define PB push_back
inline void chmax(ll &x,ll y) {x=x>y?x:y;}
inline void chmin(ll &x,ll y) {x=x<y?x:y;}
const int MAX_N=1e5+10;
int bin[30];
struct BIT
{
int bit[MAX_N];BIT(){memset(bit,0,sizeof bit);}
int lowbit(int x) {return x&-x;}
void add(int x,int c) {while(x<MAX_N) bit[x]+=c,x+=lowbit(x);}
int ask(int x) {int ans=0;while(x>=1) ans+=bit[x],x-=lowbit(x);return ans;}
int findk(int k)
{
int ans=0;
for(int i=20;i>=0;i--) if(ans+bin[i]<MAX_N and k>=bit[ans+bin[i]]) k-=bit[ans+bin[i]],ans+=bin[i];
return ans;
}
}bit;
pr a[MAX_N];
void main()
{
bin[0]=1;for(int i=1;i<30;i++) bin[i]=bin[i-1]<<1;
int n,m,all;scanf("%d%d%d",&n,&m,&all);
for(int i=1;i<=n;i++) a[i].FR=all-qread()+1;
for(int i=1;i<=n;i++) a[i].FR=ceil((double)a[i].FR/qread()),a[i].SE=i,bit.add(i,1);
sort(a+1,a+n+1);
ll ans=0,dec=0;int turn=1,pos=1;
for(int i=1;i<=n and turn<=m;i++)
{
int rk=bit.ask(pos);
ll tmp=a[i].FR-dec;int me=bit.ask(a[i].SE);
if(tmp>0)
{
int rk2=(tmp+rk-1)%(n-i+1),t2=(tmp+rk-1)/(n-i+1);
if(rk2==0) rk2=n-i+1,t2--;
if(turn+t2>m) {ans+=ll(m-turn)*(n-i+1)+(n-i+1-rk+1);break;}
turn+=t2;dec+=tmp;ans+=tmp;
if((me==n-i+1 and rk2==n-i) or rk2==n-i+1) rk2=1,turn++;
else if(rk2<me) rk2++;
bit.add(a[i].SE,-1);
pos=bit.findk(rk2);
}
else
{
if(rk>me) rk--;
if(rk==n-i+1) rk=1,turn++;
bit.add(a[i].SE,-1);
pos=bit.findk(rk);
}
}
printf("%lld",ans);
}
};
int main()
{
srand(time(0));
mine::main();
}