CF161C Abracadabra
Description
Polycarpus analyzes a string called abracadabra. This string is constructed using the following algorithm:
- On the first step the string consists of a single character "a".
- On the $ k $ -th step Polycarpus concatenates two copies of the string obtained on the $ (k-1) $ -th step, while inserting the $ k $ -th character of the alphabet between them. Polycarpus uses the alphabet that consists of lowercase Latin letters and digits (a total of 36 characters). The alphabet characters are numbered like this: the 1-st character is "a", the 2-nd — "b", ..., the 26-th — "z", the 27-th — "0", the 28-th — "1", ..., the 36-th — "9".
Let's have a closer look at the algorithm. On the second step Polycarpus will concatenate two strings "a" and insert the character "b" between them, resulting in "aba" string. The third step will transform it into "abacaba", and the fourth one - into "abacabadabacaba". Thus, the string constructed on the $ k $ -th step will consist of $ 2^{k}-1 $ characters.
Polycarpus wrote down the string he got after 30 steps of the given algorithm and chose two non-empty substrings of it. Your task is to find the length of the longest common substring of the two substrings selected by Polycarpus.
A substring $ s[i...\ j] $ ( $ 1
Input Format
The input consists of a single line containing four integers $ l_{1} $ , $ r_{1} $ , $ l_{2} $ , $ r_{2} $ ( $ 1
Output Format
Print a single number — the length of the longest common substring of the given strings. If there are no common substrings, print 0.
Explanation/Hint
In the first sample the first substring is "acab", the second one is "abac". These two substrings have two longest common substrings "ac" and "ab", but we are only interested in their length — 2.
In the second sample the first substring is "a", the second one is "c". These two substrings don't have any common characters, so the length of their longest common substring is 0.