https://www.acmicpc.net/problem/2839
#include <iostream>
using namespace std;
int main() {
int num;
cin>>num;
int f = num/5;
while(f != -1){
if((num - (f * 5))%3 == 0){
cout<<f + (num - (f * 5))/3<<endl;
return 0;
}
else
f--;
}
cout<<-1<<endl;
return 0;
}
#include <cstdio>
int main(){
int n, t=0;
scanf("%d",&n);
for(;n>=0&&n%5;n-=3,t++);
printf("%d", n<0?-1:n/5+t);
return 0;
}