import java.util.Scanner; public class CinemaVoucher { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int voucherValue = Integer.parseInt(scanner.nextLine()); int tickets = 0; int other = 0; int price; String command = scanner.nextLine(); while (!command.equals("End")) { String purchase = command; if (purchase.length() > 8) { price = purchase.charAt(0) + purchase.charAt(1); } else { price = purchase.charAt(0); } if (price > voucherValue) { break; } if (purchase.length() > 8) { tickets++; } else { other++; } voucherValue = voucherValue - price; command = scanner.nextLine(); } System.out.println(tickets); System.out.println(other); } }