#include<bits/stdc++.h>
using namespace std;
int x,y,l,r,k;
int s[10000010];
int main()
{
ios :: sync_with_stdio(0);
cin >> x >> y >> l >> r >> k;
for (int v = x;v <= y;v ++)
{
for (int i = 1;i < v;i ++)
{
s[i] ++;
for (int j = 0;j < v;j ++)
{
if(i != j)
{
int h = 0;
bool e = 0;
while(h <= l)
{
switch(e)
{
case 0:
h = h * v + i;
break;
case 1:
h = h * v + j;
break;
}
e = 1 - e;
if(h >= l && h <= r && h > 9)
{
s[h] ++;
}
}
}
}
}
}
for (int i = l;i <= r;i ++)
{
if(s[i] == k)
{
cout << i << endl;
}
}
return 0;
}