import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.WeekFields;
import java.util.Locale;

public class Main {
	public static void main(String[] args) {
		// Test
		System.out.println(getDayOfWeekValue(LocalDateTime.of(2021, 11, 5, 17, 14, 24)));
	}

	static int getDayOfWeekValue(LocalDateTime input) {
		return Math.toIntExact(
				ChronoUnit.DAYS.between(
						input.with(
								TemporalAdjusters.previousOrSame(
										WeekFields.of(Locale.US)
											.getFirstDayOfWeek())), 
						input.plusDays(1))); 
		// Note: One day has been added as ChronoUnit.DAYS.between excludes
		// the second parameter while calculating the number of days
	}
}
