#include <stdio.h>
#include <iostream>
int h[5]={15,10,1,1,1};
int r[5]={1,2,3,2,1};
int c[5]={6,3,2,3,6};
int opt[7][6];
int cal(int v,int type)
{
if (type==5)
{
if (v==0)
return 0;
else
return -10000;
}
else if (v<0)
return -10000;
else if (v==0)
return 0;
else if (opt[v][type]!=-1)
return opt[v][type];
int max=-10000;
for (int j=0;j<=c[type];j++)
{
int x=cal(v-j*r[type],type+1);
if (x!=-10000)
{
x+=h[type]*j;
if (x>max)
{
max=x;
}
}
}
opt[v][type]=max;
return opt[v][type];
}
void main()
{
for (int m=0;m<7;m++)
for (int n=0;n<6;n++)
opt[m][n]=-1;
int z=cal(6,0);
printf("%d",z);
}