这是一个背包问题
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[][] dp=new int[n+1][4];
        int[] nums=new int[]{3,5,7};
        for(int i=0;i<=n;i++)
            dp[i][0]=Integer.MAX_VALUE;
        //dp[n][3]=;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=3;j++){
                if(i-nums[j-1]<0)
                    dp[i][j]=dp[i][j-1];
                else{
                    if(dp[i-nums[j-1]][j]==Integer.MAX_VALUE)
                        dp[i-nums[j-1]][j]=Integer.MAX_VALUE-1;
                    dp[i][j]=Math.min(dp[i][j-1],dp[i-nums[j-1]][j]+1);
                }
                    
            }
            
        }
        System.out.println(dp[n][3]==Integer.MAX_VALUE?-1:dp[n][3]);
    }
}