#C8038. Prime Palindrome Finder

    ID: 51976 Type: Default 1000ms 256MiB

Prime Palindrome Finder

Prime Palindrome Finder

You are given an integer \(x\). Your task is to find the smallest number \(p\) such that \(p \ge x\), \(p\) is a prime number, and \(p\) is a palindrome.

A number \(n\) is considered prime if it has no divisors other than 1 and \(n\) itself, and it is a palindrome if it reads the same forwards and backwards.

inputFormat

Input consists of a single line containing an integer (x) (1 (\le) x (\le) 105).

outputFormat

Output a single integer, which is the smallest prime palindromic number greater than or equal to (x).## sample

6
7