All problems

Problem 525

Student Attendance Record

Easy · 10 pts · String

Problem

A student's attendance record is a string of the letters A (absent), L (late) and P (present), one per day. The student is eligible for an award if they were absent on fewer than 2 days in total and were never late on 3 or more days in a row. Given the record, decide whether the student is eligible. Being late 3 times in total is fine as long as those days are not consecutive.

Input

A single string R made of the letters A, L and P.

Output

Print YES if the student is eligible, otherwise NO.

Constraints

1 <= |R| <= 1000

Example input

PPALLP

Example output

YES

Explanation

The record PPALLP has one absence and at most two late days in a row, so the student is eligible and the answer is YES. PPALLL would fail because of three late days in a row.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Valid Word Abbreviation Next: Custom Sort String