import java.io.*;
/**
 * Count and display the number of bytes in the specified file
 * @author Diomidis Spinellis
 */
class ByteCount {
    public static void main(String args[]) {
	if (args.length != 1) {
	    System.err.println("Usage: ByteCount file");
	    System.exit(1);
	}
	// Try with resources; will auto-close in
	try (var in = new BufferedInputStream(new FileInputStream(args[0]))) {
            // Count bytes
            int count = 0;
	    int b;
	    while ((b = in.read()) != -1)
		count++;
            System.out.println(count);
	} catch (FileNotFoundException e) {
	    System.err.println("Unable to open file " + args[0] + ": " + e.getMessage());
	    System.exit(1);
	} catch (IOException e) {
	    System.err.println("Error reading byte: " + e.getMessage());
	    System.exit(1);
	}
    }
}