public class Solution {

    public static void main(String[] args) throws Exception {

        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String fileName = bufferedReader.readLine();
        bufferedReader.close();

        if(args.length<4) return;
        else if (args[0].equals("-c")){
        args[1] = "Куртка для сноубордистов, разм";
        args[2] = "13";
        args[3] = "123";
        addToPrice(fileName,args[1],Float.parseFloat(args[2]), Integer.parseInt(args[3]));
        }

    }


    public static String formatMethod(String s, int i){
        s=String.format("%-"+i+"s",s);
        return s;
    }

    public static void addToPrice(String fileName, String productName, float price, int quantity) throws IOException{
        int idSize = 8;
        int productNameSize = 30;
        int priceSize = 8;
        int quantitySize = 4;

        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName,true)));
        bufferedWriter.newLine();
        String newLine;
        newLine =
              formatMethod(String.valueOf(findMaxID(fileName)),idSize)
            + formatMethod(productName,productNameSize)
            + formatMethod(String.valueOf(String.format("%.2f",price)), priceSize)
            + formatMethod(String.valueOf(quantity),quantitySize);

        bufferedWriter.write(newLine);
        bufferedWriter.close();


    }
    public static int findMaxID(String fileName) throws IOException{
        ArrayList<String> idStrind = new ArrayList<>();
        int maxID = 0;
        int newId = 0;
        String s;
        BufferedReader reader =
                new BufferedReader(
                    new InputStreamReader(
                        new FileInputStream(fileName)));

        while ((s = reader.readLine())!=null){
                idStrind.add(s);}

        reader.close();

        for(int i = 0; i <idStrind.size(); i++){
            s = String.valueOf(idStrind.get(i).charAt(0));
            for(int j = 1;j<8; j++){
                   if(idStrind.get(i).charAt(j)==' '){
                       break;
                   }
                    s= s + idStrind.get(i).charAt(j);
                }

                int id = Integer.parseInt(s);
                s=null;
                if(id>maxID){maxID=id;}
            }
                newId = maxID + 1;

        return newId;
    }

}