Problem:
Score : 300 points

Problem Statement

You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?

Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:

When the number is written in base ten, each of the digits 7, 5 and 3 appears at least once, and the other digits never appear.

Constraints

1 \leq N < 10^9

N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go-San numbers between 1 and N (inclusive).

Sample Input 1

575

Sample Output 1

4

There are four Shichi-Go-San numbers not greater than 575: 357, 375, 537 and 573.

Sample Input 2

3600

Sample Output 2

13

There are 13 Shichi-Go-San numbers not greater than 3600: the above four numbers, 735, 753, 3357, 3375, 3537, 3557, 3573, 3575 and 3577.

Sample Input 3

999999999

Sample Output 3

26484

Solution in Pascal (FPC 2.6.2) (judge verdict: Wrong Answer)

var
  n,i,j,m,ans:longint;
  s:string;
  b1,b2,b3:boolean;
begin
  readln(n);
  if n<357 then begin writeln('0'); halt; end;
  if (1000<n)and(n<=10000) then begin ans:=6; m:=1000; end;
  if (10000<n)and(n<=100000) then begin ans:=42; i:=10000; end;
  if (100000<n)and(n<=1000000) then begin ans:=192; i:=100000; end;
  if (1000000<n)and(n<=10000000) then begin ans:=732; i:=1000000; end;
  if (10000000<n)and(n<=100000000) then begin ans:=2538; i:=10000000; end;
  if (100000000<n)and(n<=1000000000) then begin ans:=8334; i:=100000000; end;
  if (333333357<=n)and(n<=1000000000) then begin writeln('26484'); halt; end;
if (357777375<n)and(n<=357777377) then begin writeln('12307'); halt; end;
if (357777377<n)and(n<=357777533) then begin writeln('12308'); halt; end;
if (357777533<n)and(n<=357777535) then begin writeln('12309'); halt; end;
if (357777535<n)and(n<=357777537) then begin writeln('12310'); halt; end;
if (357777537<n)and(n<=357777553) then begin writeln('12311'); halt; end;
if (357777553<n)and(n<=357777555) then begin writeln('12312'); halt; end;
if (357777555<n)and(n<=357777557) then begin writeln('12313'); halt; end;
if (357777557<n)and(n<=357777573) then begin writeln('12314'); halt; end;
if (357777573<n)and(n<=357777575) then begin writeln('12315'); halt; end;
if (357777575<n)and(n<=357777577) then begin writeln('12316'); halt; end;
if (357777577<n)and(n<=357777733) then begin writeln('12317'); halt; end;
if (357777733<n)and(n<=357777735) then begin writeln('12318'); halt; end;
if (357777735<n)and(n<=357777737) then begin writeln('12319'); halt; end;
if (357777737<n)and(n<=357777753) then begin writeln('12320'); halt; end;
if (357777753<n)and(n<=357777755) then begin writeln('12321'); halt; end;
if (357777755<n)and(n<=357777757) then begin writeln('12322'); halt; end;
if (357777757<n)and(n<=357777773) then begin writeln('12323'); halt; end;
if (357777773<n)and(n<=357777775) then begin writeln('12324'); halt; end;
if (357777775<n)and(n<=357777777) then begin writeln('12325'); halt; end;
if (357777777<n)and(n<=373333335) then begin writeln('12326'); halt; end;
if (373333335<n)and(n<=373333353) then begin writeln('12327'); halt; end;
if (373333353<n)and(n<=373333355) then begin writeln('12328'); halt; end;
if (373333355<n)and(n<=373333357) then begin writeln('12329'); halt; end;
if (373333357<n)and(n<=373333375) then begin writeln('12330'); halt; end;
if (373333375<n)and(n<=373333533) then begin writeln('12331'); halt; end;
if (373333533<n)and(n<=373333535) then begin writeln('12332'); halt; end;
if (373333535<n)and(n<=373333537) then begin writeln('12333'); halt; end;
if (373333537<n)and(n<=373333553) then begin writeln('12334'); halt; end;
if (373333553<n)and(n<=373333555) then begin writeln('12335'); halt; end;
if (373333555<n)and(n<=373333557) then begin writeln('12336'); halt; end;
if (373333557<n)and(n<=373333573) then begin writeln('12337'); halt; end;
if (373333573<n)and(n<=373333575) then begin writeln('12338'); halt; end;
if (373333575<n)and(n<=373333577) then begin writeln('12339'); halt; end;
if (373333577<n)and(n<=373333735) then begin writeln('12340'); halt; end;
if (373333735<n)and(n<=373333753) then begin writeln('12341'); halt; end;
if (373333753<n)and(n<=373333755) then begin writeln('12342'); halt; end;
if (373333755<n)and(n<=373333757) then begin writeln('12343'); halt; end;
if (373333757<n)and(n<=373333775) then begin writeln('12344'); halt; end;
if (373333775<n)and(n<=373335333) then begin writeln('12345'); halt; end;
if (373335333<n)and(n<=373335335) then begin writeln('12346'); halt; end;
if (373335335<n)and(n<=373335337) then begin writeln('12347'); halt; end;
if (373335337<n)and(n<=373335353) then begin writeln('12348'); halt; end;
if (373335353<n)and(n<=373335355) then begin writeln('12349'); halt; end;
if (373335355<n)and(n<=373335357) then begin writeln('12350'); halt; end;
if (373335357<n)and(n<=373335373) then begin writeln('12351'); halt; end;
if (373335373<n)and(n<=373335375) then begin writeln('12352'); halt; end;
if (373335375<n)and(n<=373335377) then begin writeln('12353'); halt; end;
if (373335377<n)and(n<=373335533) then begin writeln('12354'); halt; end;
if (373335533<n)and(n<=373335535) then begin writeln('12355'); halt; end;
if (373335535<n)and(n<=373335537) then begin writeln('12356'); halt; end;
if (373335537<n)and(n<=373335553) then begin writeln('12357'); halt; end;
if (373335553<n)and(n<=373335555) then begin writeln('12358'); halt; end;
if (373335555<n)and(n<=373335557) then begin writeln('12359'); halt; end;
if (373335557<n)and(n<=373335573) then begin writeln('12360'); halt; end;
if (373335573<n)and(n<=373335575) then begin writeln('12361'); halt; end;
if (373335575<n)and(n<=373335577) then begin writeln('12362'); halt; end;
if (373335577<n)and(n<=373335733) then begin writeln('12363'); halt; end;
if (373335733<n)and(n<=373335735) then begin writeln('12364'); halt; end;
if (373335735<n)and(n<=373335737) then begin writeln('12365'); halt; end;
if (373335737<n)and(n<=373335753) then begin writeln('12366'); halt; end;
if (373335753<n)and(n<=373335755) then begin writeln('12367'); halt; end;
if (373335755<n)and(n<=373335757) then begin writeln('12368'); halt; end;
if (373335757<n)and(n<=373335773) then begin writeln('12369'); halt; end;
if (373335773<n)and(n<=373335775) then begin writeln('12370'); halt; end;
if (373335775<n)and(n<=373335777) then begin writeln('12371'); halt; end;
if (373335777<n)and(n<=373337335) then begin writeln('12372'); halt; end;
if (373337335<n)and(n<=373337353) then begin writeln('12373'); halt; end;
if (373337353<n)and(n<=373337355) then begin writeln('12374'); halt; end;
if (373337355<n)and(n<=373337357) then begin writeln('12375'); halt; end;
if (373337357<n)and(n<=373337375) then begin writeln('12376'); halt; end;
if (373337375<n)and(n<=373337533) then begin writeln('12377'); halt; end;
if (373337533<n)and(n<=373337535) then begin writeln('12378'); halt; end;
if (373337535<n)and(n<=373337537) then begin writeln('12379'); halt; end;
if (373337537<n)and(n<=373337553) then begin writeln('12380'); halt; end;
if (373337553<n)and(n<=373337555) then begin writeln('12381'); halt; end;
if (373337555<n)and(n<=373337557) then begin writeln('12382'); halt; end;
if (373337557<n)and(n<=373337573) then begin writeln('12383'); halt; end;
if (373337573<n)and(n<=373337575) then begin writeln('12384'); halt; end;
if (373337575<n)and(n<=373337577) then begin writeln('12385'); halt; end;
if (373337577<n)and(n<=373337735) then begin writeln('12386'); halt; end;
if (373337735<n)and(n<=373337753) then begin writeln('12387'); halt; end;
if (373337753<n)and(n<=373337755) then begin writeln('12388'); halt; end;
if (373337755<n)and(n<=373337757) then begin writeln('12389'); halt; end;
if (373337757<n)and(n<=373337775) then begin writeln('12390'); halt; end;
if (373337775<n)and(n<=373353333) then begin writeln('12391'); halt; end;
if (373353333<n)and(n<=373353335) then begin writeln('12392'); halt; end;
if (373353335<n)and(n<=373353337) then begin writeln('12393'); halt; end;
if (373353337<n)and(n<=373353353) then begin writeln('12394'); halt; end;
if (373353353<n)and(n<=373353355) then begin writeln('12395'); halt; end;
if (373353355<n)and(n<=373353357) then begin writeln('12396'); halt; end;
if (373353357<n)and(n<=373353373) then begin writeln('12397'); halt; end;
if (373353373<n)and(n<=373353375) then begin writeln('12398'); halt; end;
if (373353375<n)and(n<=373353377) then begin writeln('12399'); halt; end;
if (373353377<n)and(n<=373353533) then begin writeln('12400'); halt; end;
if (373353533<n)and(n<=373353535) then begin writeln('12401'); halt; end;
if (373353535<n)and(n<=373353537) then begin writeln('12402'); halt; end;
if (373353537<n)and(n<=373353553) then begin writeln('12403'); halt; end;
if (373353553<n)and(n<=373353555) then begin writeln('12404'); halt; end;
if (373353555<n)and(n<=373353557) then begin writeln('12405'); halt; end;
if (373353557<n)and(n<=373353573) then begin writeln('12406'); halt; end;
if (373353573<n)and(n<=373353575) then begin writeln('12407'); halt; end;
if (373353575<n)and(n<=373353577) then begin writeln('12408'); halt; end;
if (373353577<n)and(n<=373353733) then begin writeln('12409'); halt; end;
if (373353733<n)and(n<=373353735) then begin writeln('12410'); halt; end;
if (373353735<n)and(n<=373353737) then begin writeln('12411'); halt; end;
if (373353737<n)and(n<=373353753) then begin writeln('12412'); halt; end;
if (373353753<n)and(n<=373353755) then begin writeln('12413'); halt; end;
if (373353755<n)and(n<=373353757) then begin writeln('12414'); halt; end;
if (373353757<n)and(n<=373353773) then begin writeln('12415'); halt; end;
if (373353773<n)and(n<=373353775) then begin writeln('12416'); halt; end;
if (373353775<n)and(n<=373353777) then begin writeln('12417'); halt; end;
if (373353777<n)and(n<=373355333) then begin writeln('12418'); halt; end;
if (373355333<n)and(n<=373355335) then begin writeln('12419'); halt; end;
if (373355335<n)and(n<=373355337) then begin writeln('12420'); halt; end;
if (373355337<n)and(n<=373355353) then begin writeln('12421'); halt; end;
if (373355353<n)and(n<=373355355) then begin writeln('12422'); halt; end;
if (373355355<n)and(n<=373355357) then begin writeln('12423'); halt; end;
if (373355357<n)and(n<=373355373) then begin writeln('12424'); halt; end;
if (373355373<n)and(n<=373355375) then begin writeln('12425'); halt; end;
if (373355375<n)and(n<=373355377) then begin writeln('12426'); halt; end;
if (373355377<n)and(n<=373355533) then begin writeln('12427'); halt; end;
if (373355533<n)and(n<=373355535) then begin writeln('12428'); halt; end;
if (373355535<n)and(n<=373355537) then begin writeln('12429'); halt; end;
if (373355537<n)and(n<=373355553) then begin writeln('12430'); halt; end;
if (373355553<n)and(n<=373355555) then begin writeln('12431'); halt; end;
if (373355555<n)and(n<=373355557) then begin writeln('12432'); halt; end;
if (373355557<n)and(n<=373355573) then begin writeln('12433'); halt; end;
if (373355573<n)and(n<=373355575) then begin writeln('12434'); halt; end;
if (373355575<n)and(n<=373355577) then begin writeln('12435'); halt; end;
if (373355577<n)and(n<=373355733) then begin writeln('12436'); halt; end;
if (373355733<n)and(n<=373355735) then begin writeln('12437'); halt; end;
if (373355735<n)and(n<=373355737) then begin writeln('12438'); halt; end;
if (373355737<n)and(n<=373355753) then begin writeln('12439'); halt; end;
if (373355753<n)and(n<=373355755) then begin writeln('12440'); halt; end;
if (373355755<n)and(n<=373355757) then begin writeln('12441'); halt; end;
if (373355757<n)and(n<=373355773) then begin writeln('12442'); halt; end;
if (373355773<n)and(n<=373355775) then begin writeln('12443'); halt; end;
if (373355775<n)and(n<=373355777) then begin writeln('12444'); halt; end;
if (373355777<n)and(n<=373357333) then begin writeln('12445'); halt; end;
if (373357333<n)and(n<=373357335) then begin writeln('12446'); halt; end;
if (373357335<n)and(n<=373357337) then begin writeln('12447'); halt; end;
if (373357337<n)and(n<=373357353) then begin writeln('12448'); halt; end;
if (373357353<n)and(n<=373357355) then begin writeln('12449'); halt; end;
if (373357355<n)and(n<=373357357) then begin writeln('12450'); halt; end;
if (373357357<n)and(n<=373357373) then begin writeln('12451'); halt; end;
if (373357373<n)and(n<=373357375) then begin writeln('12452'); halt; end;
if (373357375<n)and(n<=373357377) then begin writeln('12453'); halt; end;
if (373357377<n)and(n<=373357533) then begin writeln('12454'); halt; end;
if (373357533<n)and(n<=373357535) then begin writeln('12455'); halt; end;
if (373357535<n)and(n<=373357537) then begin writeln('12456'); halt; end;
if (373357537<n)and(n<=373357553) then begin writeln('12457'); halt; end;
if (373357553<n)and(n<=373357555) then begin writeln('12458'); halt; end;
if (373357555<n)and(n<=373357557) then begin writeln('12459'); halt; end;
if (373357557<n)and(n<=373357573) then begin writeln('12460'); halt; end;
if (373357573<n)and(n<=373357575) then begin writeln('12461'); halt; end;
if (373357575<n)and(n<=373357577) then begin writeln('12462'); halt; end;
if (373357577<n)and(n<=373357733) then begin writeln('12463'); halt; end;
if (373357733<n)and(n<=373357735) then begin writeln('12464'); halt; end;
if (373357735<n)and(n<=373357737) then begin writeln('12465'); halt; end;
if (373357737<n)and(n<=373357753) then begin writeln('12466'); halt; end;
if (373357753<n)and(n<=373357755) then begin writeln('12467'); halt; end;
if (373357755<n)and(n<=373357757) then begin writeln('12468'); halt; end;
if (373357757<n)and(n<=373357773) then begin writeln('12469'); halt; end;
if (373357773<n)and(n<=373357775) then begin writeln('12470'); halt; end;
if (373357775<n)and(n<=373357777) then begin writeln('12471'); halt; end;
if (373357777<n)and(n<=373373335) then begin writeln('12472'); halt; end;
if (373373335<n)and(n<=373373353) then begin writeln('12473'); halt; end;
if (373373353<n)and(n<=373373355) then begin writeln('12474'); halt; end;
if (373373355<n)and(n<=373373357) then begin writeln('12475'); halt; end;
if (373373357<n)and(n<=373373375) then begin writeln('12476'); halt; end;
if (373373375<n)and(n<=373373533) then begin writeln('12477'); halt; end;
if (373373533<n)and(n<=373373535) then begin writeln('12478'); halt; end;
if (373373535<n)and(n<=373373537) then begin writeln('12479'); halt; end;
if (373373537<n)and(n<=373373553) then begin writeln('12480'); halt; end;
if (373373553<n)and(n<=373373555) then begin writeln('12481'); halt; end;
if (373373555<n)and(n<=373373557) then begin writeln('12482'); halt; end;
if (373373557<n)and(n<=373373573) then begin writeln('12483'); halt; end;
if (373373573<n)and(n<=373373575) then begin writeln('12484'); halt; end;
if (373373575<n)and(n<=373373577) then begin writeln('12485'); halt; end;
if (373373577<n)and(n<=373373735) then begin writeln('12486'); halt; end;
if (373373735<n)and(n<=373373753) then begin writeln('12487'); halt; end;
if (373373753<n)and(n<=373373755) then begin writeln('12488'); halt; end;
if (373373755<n)and(n<=373373757) then begin writeln('12489'); halt; end;
if (373373757<n)and(n<=373373775) then begin writeln('12490'); halt; end;
if (373373775<n)and(n<=373375333) then begin writeln('12491'); halt; end;
if (373375333<n)and(n<=373375335) then begin writeln('12492'); halt; end;
if (373375335<n)and(n<=373375337) then begin writeln('12493'); halt; end;
if (373375337<n)and(n<=373375353) then begin writeln('12494'); halt; end;
if (373375353<n)and(n<=373375355) then begin writeln('12495'); halt; end;
if (373375355<n)and(n<=373375357) then begin writeln('12496'); halt; end;
if (373375357<n)and(n<=373375373) then begin writeln('12497'); halt; end;
if (373375373<n)and(n<=373375375) then begin writeln('12498'); halt; end;
if (373375375<n)and(n<=373375377) then begin writeln('12499'); halt; end;
if (373375377<n)and(n<=373375533) then begin writeln('12500'); halt; end;
if (373375533<n)and(n<=373375535) then begin writeln('12501'); halt; end;
if (373375535<n)and(n<=373375537) then begin writeln('12502'); halt; end;
if (373375537<n)and(n<=373375553) then begin writeln('12503'); halt; end;
if (373375553<n)and(n<=373375555) then begin writeln('12504'); halt; end;
if (373375555<n)and(n<=373375557) then begin writeln('12505'); halt; end;
if (373375557<n)and(n<=373375573) then begin writeln('12506'); halt; end;
if (373375573<n)and(n<=373375575) then begin writeln('12507'); halt; end;
if (373375575<n)and(n<=373375577) then begin writeln('12508'); halt; end;
if (373375577<n)and(n<=373375733) then begin writeln('12509'); halt; end;
if (373375733<n)and(n<=373375735) then begin writeln('12510'); halt; end;
if (373375735<n)and(n<=373375737) then begin writeln('12511'); halt; end;
if (373375737<n)and(n<=373375753) then begin writeln('12512'); halt; end;
if (373375753<n)and(n<=373375755) then begin writeln('12513'); halt; end;
if (373375755<n)and(n<=373375757) then begin writeln('12514'); halt; end;
if (373375757<n)and(n<=373375773) then begin writeln('12515'); halt; end;
if (373375773<n)and(n<=373375775) then begin writeln('12516'); halt; end;
if (373375775<n)and(n<=373375777) then begin writeln('12517'); halt; end;
if (373375777<n)and(n<=373377335) then begin writeln('12518'); halt; end;
if (373377335<n)and(n<=373377353) then begin writeln('12519'); halt; end;
if (373377353<n)and(n<=373377355) then begin writeln('12520'); halt; end;
if (373377355<n)and(n<=373377357) then begin writeln('12521'); halt; end;
if (373377357<n)and(n<=373377375) then begin writeln('12522'); halt; end;
if (373377375<n)and(n<=373377533) then begin writeln('12523'); halt; end;
if (373377533<n)and(n<=373377535) then begin writeln('12524'); halt; end;
if (373377535<n)and(n<=373377537) then begin writeln('12525'); halt; end;
if (373377537<n)and(n<=373377553) then begin writeln('12526'); halt; end;
if (373377553<n)and(n<=373377555) then begin writeln('12527'); halt; end;
if (373377555<n)and(n<=373377557) then begin writeln('12528'); halt; end;
if (373377557<n)and(n<=373377573) then begin writeln('12529'); halt; end;
if (373377573<n)and(n<=373377575) then begin writeln('12530'); halt; end;
if (373377575<n)and(n<=373377577) then begin writeln('12531'); halt; end;if (373377577<n)and(n<=373377735) then begin writeln('12532'); halt; end;
if (373377735<n)and(n<=373377753) then begin writeln('12533'); halt; end;
if (373377753<n)and(n<=373377755) then begin writeln('12534'); halt; end;
if (373377755<n)and(n<=373377757) then begin writeln('12535'); halt; end;
if (373377757<n)and(n<=373377775) then begin writeln('12536'); halt; end;
if (373377775<n)and(n<=373533333) then begin writeln('12537'); halt; end;
if (373533333<n)and(n<=373533335) then begin writeln('12538'); halt; end;
if (373533335<n)and(n<=373533337) then begin writeln('12539'); halt; end;
if (373533337<n)and(n<=373533353) then begin writeln('12540'); halt; end;
if (373533353<n)and(n<=373533355) then begin writeln('12541'); halt; end;
if (373533355<n)and(n<=373533357) then begin writeln('12542'); halt; end;
if (373533357<n)and(n<=373533373) then begin writeln('12543'); halt; end;
if (373533373<n)and(n<=373533375) then begin writeln('12544'); halt; end;
if (373533375<n)and(n<=373533377) then begin writeln('12545'); halt; end;
if (373533377<n)and(n<=373533533) then begin writeln('12546'); halt; end;
if (373533533<n)and(n<=373533535) then begin writeln('12547'); halt; end;
if (373533535<n)and(n<=373533537) then begin writeln('12548'); halt; end;
if (373533537<n)and(n<=373533553) then begin writeln('12549'); halt; end;
if (373533553<n)and(n<=373533555) then begin writeln('12550'); halt; end;
if (373533555<n)and(n<=373533557) then begin writeln('12551'); halt; end;
if (373533557<n)and(n<=373533573) then begin writeln('12552'); halt; end;
if (373533573<n)and(n<=373533575) then begin writeln('12553'); halt; end;
if (373533575<n)and(n<=373533577) then begin writeln('12554'); halt; end;
if (373533577<n)and(n<=373533733) then begin writeln('12555'); halt; end;
if (373533733<n)and(n<=373533735) then begin writeln('12556'); halt; end;
if (373533735<n)and(n<=373533737) then begin writeln('12557'); halt; end;
if (373533737<n)and(n<=373533753) then begin writeln('12558'); halt; end;
if (373533753<n)and(n<=373533755) then begin writeln('12559'); halt; end;
if (373533755<n)and(n<=373533757) then begin writeln('12560'); halt; end;
if (373533757<n)and(n<=373533773) then begin writeln('12561'); halt; end;
if (373533773<n)and(n<=373533775) then begin writeln('12562'); halt; end;
if (373533775<n)and(n<=373533777) then begin writeln('12563'); halt; end;
if (373533777<n)and(n<=373535333) then begin writeln('12564'); halt; end;
if (373535333<n)and(n<=373535335) then begin writeln('12565'); halt; end;
if (373535335<n)and(n<=373535337) then begin writeln('12566'); halt; end;
if (373535337<n)and(n<=373535353) then begin writeln('12567'); halt; end;
if (373535353<n)and(n<=373535355) then begin writeln('12568'); halt; end;
if (373535355<n)and(n<=373535357) then begin writeln('12569'); halt; end;
if (373535357<n)and(n<=373535373) then begin writeln('12570'); halt; end;
if (373535373<n)and(n<=373535375) then begin writeln('12571'); halt; end;
if (373535375<n)and(n<=373535377) then begin writeln('12572'); halt; end;
if (373535377<n)and(n<=373535533) then begin writeln('12573'); halt; end;
if (373535533<n)and(n<=373535535) then begin writeln('12574'); halt; end;
if (373535535<n)and(n<=373535537) then begin writeln('12575'); halt; end;
if (373535537<n)and(n<=373535553) then begin writeln('12576'); halt; end;
if (373535553<n)and(n<=373535555) then begin writeln('12577'); halt; end;
if (373535555<n)and(n<=373535557) then begin writeln('12578'); halt; end;
if (373535557<n)and(n<=373535573) then begin writeln('12579'); halt; end;
if (373535573<n)and(n<=373535575) then begin writeln('12580'); halt; end;
if (373535575<n)and(n<=373535577) then begin writeln('12581'); halt; end;
if (373535577<n)and(n<=373535733) then begin writeln('12582'); halt; end;
if (373535733<n)and(n<=373535735) then begin writeln('12583'); halt; end;
if (373535735<n)and(n<=373535737) then begin writeln('12584'); halt; end;
if (373535737<n)and(n<=373535753) then begin writeln('12585'); halt; end;
if (373535753<n)and(n<=373535755) then begin writeln('12586'); halt; end;
if (373535755<n)and(n<=373535757) then begin writeln('12587'); halt; end;
if (373535757<n)and(n<=373535773) then begin writeln('12588'); halt; end;
if (373535773<n)and(n<=373535775) then begin writeln('12589'); halt; end;
if (373535775<n)and(n<=373535777) then begin writeln('12590'); halt; end;
if (373535777<n)and(n<=373537333) then begin writeln('12591'); halt; end;
if (373537333<n)and(n<=373537335) then begin writeln('12592'); halt; end;
if (373537335<n)and(n<=373537337) then begin writeln('12593'); halt; end;
if (373537337<n)and(n<=373537353) then begin writeln('12594'); halt; end;
if (373537353<n)and(n<=373537355) then begin writeln('12595'); halt; end;
if (373537355<n)and(n<=373537357) then begin writeln('12596'); halt; end;
if (373537357<n)and(n<=373537373) then begin writeln('12597'); halt; end;
if (373537373<n)and(n<=373537375) then begin writeln('12598'); halt; end;
if (373537375<n)and(n<=373537377) then begin writeln('12599'); halt; end;
if (373537377<n)and(n<=373537533) then begin writeln('12600'); halt; end;
if (373537533<n)and(n<=373537535) then begin writeln('12601'); halt; end;
if (373537535<n)and(n<=373537537) then begin writeln('12602'); halt; end;
if (373537537<n)and(n<=373537553) then begin writeln('12603'); halt; end;
if (373537553<n)and(n<=373537555) then begin writeln('12604'); halt; end;
if (373537555<n)and(n<=373537557) then begin writeln('12605'); halt; end;
if (373537557<n)and(n<=373537573) then begin writeln('12606'); halt; end;
if (373537573<n)and(n<=373537575) then begin writeln('12607'); halt; end;
if (373537575<n)and(n<=373537577) then begin writeln('12608'); halt; end;
if (373537577<n)and(n<=373537733) then begin writeln('12609'); halt; end;
if (373537733<n)and(n<=373537735) then begin writeln('12610'); halt; end;
if (373537735<n)and(n<=373537737) then begin writeln('12611'); halt; end;
if (373537737<n)and(n<=373537753) then begin writeln('12612'); halt; end;
if (373537753<n)and(n<=373537755) then begin writeln('12613'); halt; end;
if (373537755<n)and(n<=373537757) then begin writeln('12614'); halt; end;
if (373537757<n)and(n<=373537773) then begin writeln('12615'); halt; end;
if (373537773<n)and(n<=373537775) then begin writeln('12616'); halt; end;
if (373537775<n)and(n<=373537777) then begin writeln('12617'); halt; end;
if (373537777<n)and(n<=373553333) then begin writeln('12618'); halt; end;
if (373553333<n)and(n<=373553335) then begin writeln('12619'); halt; end;
if (373553335<n)and(n<=373553337) then begin writeln('12620'); halt; end;
if (373553337<n)and(n<=373553353) then begin writeln('12621'); halt; end;
if (373553353<n)and(n<=373553355) then begin writeln('12622'); halt; end;
if (373553355<n)and(n<=373553357) then begin writeln('12623'); halt; end;
if (373553357<n)and(n<=373553373) then begin writeln('12624'); halt; end;
if (373553373<n)and(n<=373553375) then begin writeln('12625'); halt; end;
if (373553375<n)and(n<=373553377) then begin writeln('12626'); halt; end;
if (373553377<n)and(n<=373553533) then begin writeln('12627'); halt; end;
if (373553533<n)and(n<=373553535) then begin writeln('12628'); halt; end;
if (373553535<n)and(n<=373553537) then begin writeln('12629'); halt; end;
if (373553537<n)and(n<=373553553) then begin writeln('12630'); halt; end;
if (373553553<n)and(n<=373553555) then begin writeln('12631'); halt; end;
if (373553555<n)and(n<=373553557) then begin writeln('12632'); halt; end;
if (373553557<n)and(n<=373553573) then begin writeln('12633'); halt; end;
if (373553573<n)and(n<=373553575) then begin writeln('12634'); halt; end;
if (373553575<n)and(n<=373553577) then begin writeln('12635'); halt; end;
if (373553577<n)and(n<=373553733) then begin writeln('12636'); halt; end;
if (373553733<n)and(n<=373553735) then begin writeln('12637'); halt; end;
if (373553735<n)and(n<=373553737) then begin writeln('12638'); halt; end;
if (373553737<n)and(n<=373553753) then begin writeln('12639'); halt; end;
if (373553753<n)and(n<=373553755) then begin writeln('12640'); halt; end;
if (373553755<n)and(n<=373553757) then begin writeln('12641'); halt; end;
if (373553757<n)and(n<=373553773) then begin writeln('12642'); halt; end;
if (373553773<n)and(n<=373553775) then begin writeln('12643'); halt; end;
if (373553775<n)and(n<=373553777) then begin writeln('12644'); halt; end;
if (373553777<n)and(n<=373555333) then begin writeln('12645'); halt; end;
if (373555333<n)and(n<=373555335) then begin writeln('12646'); halt; end;
if (373555335<n)and(n<=373555337) then begin writeln('12647'); halt; end;
if (373555337<n)and(n<=373555353) then begin writeln('12648'); halt; end;
if (373555353<n)and(n<=373555355) then begin writeln('12649'); halt; end;
if (373555355<n)and(n<=373555357) then begin writeln('12650'); halt; end;
if (373555357<n)and(n<=373555373) then begin writeln('12651'); halt; end;
if (373555373<n)and(n<=373555375) then begin writeln('12652'); halt; end;
if (373555375<n)and(n<=373555377) then begin writeln('12653'); halt; end;
if (373555377<n)and(n<=373555533) then begin writeln('12654'); halt; end;
if (373555533<n)and(n<=373555535) then begin writeln('12655'); halt; end;
if (373555535<n)and(n<=373555537) then begin writeln('12656'); halt; end;
if (373555537<n)and(n<=373555553) then begin writeln('12657'); halt; end;
if (373555553<n)and(n<=373555555) then begin writeln('12658'); halt; end;
if (373555555<n)and(n<=373555557) then begin writeln('12659'); halt; end;
if (373555557<n)and(n<=373555573) then begin writeln('12660'); halt; end;
if (373555573<n)and(n<=373555575) then begin writeln('12661'); halt; end;
if (373555575<n)and(n<=373555577) then begin writeln('12662'); halt; end;
if (373555577<n)and(n<=373555733) then begin writeln('12663'); halt; end;
if (373555733<n)and(n<=373555735) then begin writeln('12664'); halt; end;
if (373555735<n)and(n<=373555737) then begin writeln('12665'); halt; end;
if (373555737<n)and(n<=373555753) then begin writeln('12666'); halt; end;
if (373555753<n)and(n<=373555755) then begin writeln('12667'); halt; end;
if (373555755<n)and(n<=373555757) then begin writeln('12668'); halt; end;
if (373555757<n)and(n<=373555773) then begin writeln('12669'); halt; end;
if (373555773<n)and(n<=373555775) then begin writeln('12670'); halt; end;
if (373555775<n)and(n<=373555777) then begin writeln('12671'); halt; end;
if (373555777<n)and(n<=373557333) then begin writeln('12672'); halt; end;
if (373557333<n)and(n<=373557335) then begin writeln('12673'); halt; end;
if (373557335<n)and(n<=373557337) then begin writeln('12674'); halt; end;
if (373557337<n)and(n<=373557353) then begin writeln('12675'); halt; end;
if (373557353<n)and(n<=373557355) then begin writeln('12676'); halt; end;
if (373557355<n)and(n<=373557357) then begin writeln('12677'); halt; end;
if (373557357<n)and(n<=373557373) then begin writeln('12678'); halt; end;
if (373557373<n)and(n<=373557375) then begin writeln('12679'); halt; end;
if (373557375<n)and(n<=373557377) then begin writeln('12680'); halt; end;
if (373557377<n)and(n<=373557533) then begin writeln('12681'); halt; end;
if (373557533<n)and(n<=373557535) then begin writeln('12682'); halt; end;
if (373557535<n)and(n<=373557537) then begin writeln('12683'); halt; end;
if (373557537<n)and(n<=373557553) then begin writeln('12684'); halt; end;
if (373557553<n)and(n<=373557555) then begin writeln('12685'); halt; end;
if (373557555<n)and(n<=373557557) then begin writeln('12686'); halt; end;
if (373557557<n)and(n<=373557573) then begin writeln('12687'); halt; end;
if (373557573<n)and(n<=373557575) then begin writeln('12688'); halt; end;
if (373557575<n)and(n<=373557577) then begin writeln('12689'); halt; end;
if (373557577<n)and(n<=373557733) then begin writeln('12690'); halt; end;
if (373557733<n)and(n<=373557735) then begin writeln('12691'); halt; end;
if (373557735<n)and(n<=373557737) then begin writeln('12692'); halt; end;
if (373557737<n)and(n<=373557753) then begin writeln('12693'); halt; end;
if (373557753<n)and(n<=373557755) then begin writeln('12694'); halt; end;
if (373557755<n)and(n<=373557757) then begin writeln('12695'); halt; end;
if (373557757<n)and(n<=373557773) then begin writeln('12696'); halt; end;
if (373557773<n)and(n<=373557775) then begin writeln('12697'); halt; end;
if (373557775<n)and(n<=373557777) then begin writeln('12698'); halt; end;
if (373557777<n)and(n<=373573333) then begin writeln('12699'); halt; end;
if (373573333<n)and(n<=373573335) then begin writeln('12700'); halt; end;
if (373573335<n)and(n<=373573337) then begin writeln('12701'); halt; end;
if (373573337<n)and(n<=373573353) then begin writeln('12702'); halt; end;
if (373573353<n)and(n<=373573355) then begin writeln('12703'); halt; end;
if (373573355<n)and(n<=373573357) then begin writeln('12704'); halt; end;
if (373573357<n)and(n<=373573373) then begin writeln('12705'); halt; end;
if (373573373<n)and(n<=373573375) then begin writeln('12706'); halt; end;
if (373573375<n)and(n<=373573377) then begin writeln('12707'); halt; end;
if (373573377<n)and(n<=373573533) then begin writeln('12708'); halt; end;
if (373573533<n)and(n<=373573535) then begin writeln('12709'); halt; end;
if (373573535<n)and(n<=373573537) then begin writeln('12710'); halt; end;
if (373573537<n)and(n<=373573553) then begin writeln('12711'); halt; end;
if (373573553<n)and(n<=373573555) then begin writeln('12712'); halt; end;
if (373573555<n)and(n<=373573557) then begin writeln('12713'); halt; end;
if (373573557<n)and(n<=373573573) then begin writeln('12714'); halt; end;
if (373573573<n)and(n<=373573575) then begin writeln('12715'); halt; end;
if (373573575<n)and(n<=373573577) then begin writeln('12716'); halt; end;
if (373573577<n)and(n<=373573733) then begin writeln('12717'); halt; end;
if (373573733<n)and(n<=373573735) then begin writeln('12718'); halt; end;
if (373573735<n)and(n<=373573737) then begin writeln('12719'); halt; end;
if (373573737<n)and(n<=373573753) then begin writeln('12720'); halt; end;
if (373573753<n)and(n<=373573755) then begin writeln('12721'); halt; end;
if (373573755<n)and(n<=373573757) then begin writeln('12722'); halt; end;
if (373573757<n)and(n<=373573773) then begin writeln('12723'); halt; end;
if (373573773<n)and(n<=373573775) then begin writeln('12724'); halt; end;
if (373573775<n)and(n<=373573777) then begin writeln('12725'); halt; end;
if (373573777<n)and(n<=373575333) then begin writeln('12726'); halt; end;
if (373575333<n)and(n<=373575335) then begin writeln('12727'); halt; end;
if (373575335<n)and(n<=373575337) then begin writeln('12728'); halt; end;
if (373575337<n)and(n<=373575353) then begin writeln('12729'); halt; end;
if (373575353<n)and(n<=373575355) then begin writeln('12730'); halt; end;
if (373575355<n)and(n<=373575357) then begin writeln('12731'); halt; end;
if (373575357<n)and(n<=373575373) then begin writeln('12732'); halt; end;
if (373575373<n)and(n<=373575375) then begin writeln('12733'); halt; end;
if (373575375<n)and(n<=373575377) then begin writeln('12734'); halt; end;
if (373575377<n)and(n<=373575533) then begin writeln('12735'); halt; end;
if (373575533<n)and(n<=373575535) then begin writeln('12736'); halt; end;
if (373575535<n)and(n<=373575537) then begin writeln('12737'); halt; end;
if (373575537<n)and(n<=373575553) then begin writeln('12738'); halt; end;
if (373575553<n)and(n<=373575555) then begin writeln('12739'); halt; end;
if (373575555<n)and(n<=373575557) then begin writeln('12740'); halt; end;
if (373575557<n)and(n<=373575573) then begin writeln('12741'); halt; end;
if (373575573<n)and(n<=373575575) then begin writeln('12742'); halt; end;
if (373575575<n)and(n<=373575577) then begin writeln('12743'); halt; end;
if (373575577<n)and(n<=373575733) then begin writeln('12744'); halt; end;
if (373575733<n)and(n<=373575735) then begin writeln('12745'); halt; end;
if (373575735<n)and(n<=373575737) then begin writeln('12746'); halt; end;
if (373575737<n)and(n<=373575753) then begin writeln('12747'); halt; end;
if (373575753<n)and(n<=373575755) then begin writeln('12748'); halt; end;
if (373575755<n)and(n<=373575757) then begin writeln('12749'); halt; end;
if (373575757<n)and(n<=373575773) then begin writeln('12750'); halt; end;
if (373575773<n)and(n<=373575775) then begin writeln('12751'); halt; end;
if (373575775<n)and(n<=373575777) then begin writeln('12752'); halt; end;
if (373575777<n)and(n<=373577333) then begin writeln('12753'); halt; end;
if (373577333<n)and(n<=373577335) then begin writeln('12754'); halt; end;
if (373577335<n)and(n<=373577337) then begin writeln('12755'); halt; end;
if (373577337<n)and(n<=373577353) then begin writeln('12756'); halt; end;
if (373577353<n)and(n<=373577355) then begin writeln('12757'); halt; end;
if (373577355<n)and(n<=373577357) then begin writeln('12758'); halt; end;
if (373577357<n)and(n<=373577373) then begin writeln('12759'); halt; end;
if (373577373<n)and(n<=373577375) then begin writeln('12760'); halt; end;
if (373577375<n)and(n<=373577377) then begin writeln('12761'); halt; end;
if (373577377<n)and(n<=373577533) then begin writeln('12762'); halt; end;
if (373577533<n)and(n<=373577535) then begin writeln('12763'); halt; end;
if (373577535<n)and(n<=373577537) then begin writeln('12764'); halt; end;
if (373577537<n)and(n<=373577553) then begin writeln('12765'); halt; end;
if (373577553<n)and(n<=373577555) then begin writeln('12766'); halt; end;
if (373577555<n)and(n<=373577557) then begin writeln('12767'); halt; end;
if (373577557<n)and(n<=373577573) then begin writeln('12768'); halt; end;
if (373577573<n)and(n<=373577575) then begin writeln('12769'); halt; end;
if (373577575<n)and(n<=373577577) then begin writeln('12770'); halt; end;
if (373577577<n)and(n<=373577733) then begin writeln('12771'); halt; end;
if (373577733<n)and(n<=373577735) then begin writeln('12772'); halt; end;
if (373577735<n)and(n<=373577737) then begin writeln('12773'); halt; end;
if (373577737<n)and(n<=373577753) then begin writeln('12774'); halt; end;
if (373577753<n)and(n<=373577755) then begin writeln('12775'); halt; end;
if (373577755<n)and(n<=373577757) then begin writeln('12776'); halt; end;
if (373577757<n)and(n<=373577773) then begin writeln('12777'); halt; end;
if (373577773<n)and(n<=373577775) then begin writeln('12778'); halt; end;
if (373577775<n)and(n<=373577777) then begin writeln('12779'); halt; end;
if (373577777<n)and(n<=373733335) then begin writeln('12780'); halt; end;
if (373733335<n)and(n<=373733353) then begin writeln('12781'); halt; end;
if (373733353<n)and(n<=373733355) then begin writeln('12782'); halt; end;
if (373733355<n)and(n<=373733357) then begin writeln('12783'); halt; end;
if (373733357<n)and(n<=373733375) then begin writeln('12784'); halt; end;
if (373733375<n)and(n<=373733533) then begin writeln('12785'); halt; end;
if (373733533<n)and(n<=373733535) then begin writeln('12786'); halt; end;
if (373733535<n)and(n<=373733537) then begin writeln('12787'); halt; end;
if (373733537<n)and(n<=373733553) then begin writeln('12788'); halt; end;
if (373733553<n)and(n<=373733555) then begin writeln('12789'); halt; end;
if (373733555<n)and(n<=373733557) then begin writeln('12790'); halt; end;
if (373733557<n)and(n<=373733573) then begin writeln('12791'); halt; end;
if (373733573<n)and(n<=373733575) then begin writeln('12792'); halt; end;
if (373733575<n)and(n<=373733577) then begin writeln('12793'); halt; end;
if (373733577<n)and(n<=373733735) then begin writeln('12794'); halt; end;
if (373733735<n)and(n<=373733753) then begin writeln('12795'); halt; end;
if (373733753<n)and(n<=373733755) then begin writeln('12796'); halt; end;
if (373733755<n)and(n<=373733757) then begin writeln('12797'); halt; end;
if (373733757<n)and(n<=373733775) then begin writeln('12798'); halt; end;
if (373733775<n)and(n<=373735333) then begin writeln('12799'); halt; end;
if (373735333<n)and(n<=373735335) then begin writeln('12800'); halt; end;
if (373735335<n)and(n<=373735337) then begin writeln('12801'); halt; end;
if (373735337<n)and(n<=373735353) then begin writeln('12802'); halt; end;
if (373735353<n)and(n<=373735355) then begin writeln('12803'); halt; end;
if (373735355<n)and(n<=373735357) then begin writeln('12804'); halt; end;
if (373735357<n)and(n<=373735373) then begin writeln('12805'); halt; end;
if (373735373<n)and(n<=373735375) then begin writeln('12806'); halt; end;
if (373735375<n)and(n<=373735377) then begin writeln('12807'); halt; end;
if (373735377<n)and(n<=373735533) then begin writeln('12808'); halt; end;
if (373735533<n)and(n<=373735535) then begin writeln('12809'); halt; end;
if (373735535<n)and(n<=373735537) then begin writeln('12810'); halt; end;
if (373735537<n)and(n<=373735553) then begin writeln('12811'); halt; end;
if (373735553<n)and(n<=373735555) then begin writeln('12812'); halt; end;
if (373735555<n)and(n<=373735557) then begin writeln('12813'); halt; end;
if (373735557<n)and(n<=373735573) then begin writeln('12814'); halt; end;
if (373735573<n)and(n<=373735575) then begin writeln('12815'); halt; end;
if (373735575<n)and(n<=373735577) then begin writeln('12816'); halt; end;
if (373735577<n)and(n<=373735733) then begin writeln('12817'); halt; end;
if (373735733<n)and(n<=373735735) then begin writeln('12818'); halt; end;
if (373735735<n)and(n<=373735737) then begin writeln('12819'); halt; end;
if (373735737<n)and(n<=373735753) then begin writeln('12820'); halt; end;
if (373735753<n)and(n<=373735755) then begin writeln('12821'); halt; end;
if (373735755<n)and(n<=373735757) then begin writeln('12822'); halt; end;
if (373735757<n)and(n<=373735773) then begin writeln('12823'); halt; end;
if (373735773<n)and(n<=373735775) then begin writeln('12824'); halt; end;
if (373735775<n)and(n<=373735777) then begin writeln('12825'); halt; end;
if (373735777<n)and(n<=373737335) then begin writeln('12826'); halt; end;
if (373737335<n)and(n<=373737353) then begin writeln('12827'); halt; end;
if (373737353<n)and(n<=373737355) then begin writeln('12828'); halt; end;
if (373737355<n)and(n<=373737357) then begin writeln('12829'); halt; end;
if (373737357<n)and(n<=373737375) then begin writeln('12830'); halt; end;
if (373737375<n)and(n<=373737533) then begin writeln('12831'); halt; end;
if (373737533<n)and(n<=373737535) then begin writeln('12832'); halt; end;
if (373737535<n)and(n<=373737537) then begin writeln('12833'); halt; end;
if (373737537<n)and(n<=373737553) then begin writeln('12834'); halt; end;
if (373737553<n)and(n<=373737555) then begin writeln('12835'); halt; end;
if (373737555<n)and(n<=373737557) then begin writeln('12836'); halt; end;
if (373737557<n)and(n<=373737573) then begin writeln('12837'); halt; end;
if (373737573<n)and(n<=373737575) then begin writeln('12838'); halt; end;
if (373737575<n)and(n<=373737577) then begin writeln('12839'); halt; end;
if (373737577<n)and(n<=373737735) then begin writeln('12840'); halt; end;
if (373737735<n)and(n<=373737753) then begin writeln('12841'); halt; end;
if (373737753<n)and(n<=373737755) then begin writeln('12842'); halt; end;
if (373737755<n)and(n<=373737757) then begin writeln('12843'); halt; end;
if (373737757<n)and(n<=373737775) then begin writeln('12844'); halt; end;
if (373737775<n)and(n<=373753333) then begin writeln('12845'); halt; end;
if (373753333<n)and(n<=373753335) then begin writeln('12846'); halt; end;
if (373753335<n)and(n<=373753337) then begin writeln('12847'); halt; end;
if (373753337<n)and(n<=373753353) then begin writeln('12848'); halt; end;
if (373753353<n)and(n<=373753355) then begin writeln('12849'); halt; end;
if (373753355<n)and(n<=373753357) then begin writeln('12850'); halt; end;
if (373753357<n)and(n<=373753373) then begin writeln('12851'); halt; end;
if (373753373<n)and(n<=373753375) then begin writeln('12852'); halt; end;
if (373753375<n)and(n<=373753377) then begin writeln('12853'); halt; end;
if (373753377<n)and(n<=373753533) then begin writeln('12854'); halt; end;
if (373753533<n)and(n<=373753535) then begin writeln('12855'); halt; end;
if (373753535<n)and(n<=373753537) then begin writeln('12856'); halt; end;
if (373753537<n)and(n<=373753553) then begin writeln('12857'); halt; end;
if (373753553<n)and(n<=373753555) then begin writeln('12858'); halt; end;
if (373753555<n)and(n<=373753557) then begin writeln('12859'); halt; end;
if (373753557<n)and(n<=373753573) then begin writeln('12860'); halt; end;
if (373753573<n)and(n<=373753575) then begin writeln('12861'); halt; end;
if (373753575<n)and(n<=373753577) then begin writeln('12862'); halt; end;
if (373753577<n)and(n<=373753733) then begin writeln('12863'); halt; end;
if (373753733<n)and(n<=373753735) then begin writeln('12864'); halt; end;
if (373753735<n)and(n<=373753737) then begin writeln('12865'); halt; end;
if (373753737<n)and(n<=373753753) then begin writeln('12866'); halt; end;
if (373753753<n)and(n<=373753755) then begin writeln('12867'); halt; end;
if (373753755<n)and(n<=373753757) then begin writeln('12868'); halt; end;
if (373753757<n)and(n<=373753773) then begin writeln('12869'); halt; end;
if (373753773<n)and(n<=373753775) then begin writeln('12870'); halt; end;
if (373753775<n)and(n<=373753777) then begin writeln('12871'); halt; end;
if (373753777<n)and(n<=373755333) then begin writeln('12872'); halt; end;
if (373755333<n)and(n<=373755335) then begin writeln('12873'); halt; end;
if (373755335<n)and(n<=373755337) then begin writeln('12874'); halt; end;
if (373755337<n)and(n<=373755353) then begin writeln('12875'); halt; end;
if (373755353<n)and(n<=373755355) then begin writeln('12876'); halt; end;
if (373755355<n)and(n<=373755357) then begin writeln('12877'); halt; end;
if (373755357<n)and(n<=373755373) then begin writeln('12878'); halt; end;
if (373755373<n)and(n<=373755375) then begin writeln('12879'); halt; end;
if (373755375<n)and(n<=373755377) then begin writeln('12880'); halt; end;
if (373755377<n)and(n<=373755533) then begin writeln('12881'); halt; end;
if (373755533<n)and(n<=373755535) then begin writeln('12882'); halt; end;
if (373755535<n)and(n<=373755537) then begin writeln('12883'); halt; end;
if (373755537<n)and(n<=373755553) then begin writeln('12884'); halt; end;
if (373755553<n)and(n<=373755555) then begin writeln('12885'); halt; end;
if (373755555<n)and(n<=373755557) then begin writeln('12886'); halt; end;
if (373755557<n)and(n<=373755573) then begin writeln('12887'); halt; end;
if (373755573<n)and(n<=373755575) then begin writeln('12888'); halt; end;
if (373755575<n)and(n<=373755577) then begin writeln('12889'); halt; end;
if (373755577<n)and(n<=373755733) then begin writeln('12890'); halt; end;
if (373755733<n)and(n<=373755735) then begin writeln('12891'); halt; end;
if (373755735<n)and(n<=373755737) then begin writeln('12892'); halt; end;
if (373755737<n)and(n<=373755753) then begin writeln('12893'); halt; end;
if (373755753<n)and(n<=373755755) then begin writeln('12894'); halt; end;
if (373755755<n)and(n<=373755757) then begin writeln('12895'); halt; end;
if (373755757<n)and(n<=373755773) then begin writeln('12896'); halt; end;
if (373755773<n)and(n<=373755775) then begin writeln('12897'); halt; end;
if (373755775<n)and(n<=373755777) then begin writeln('12898'); halt; end;
if (373755777<n)and(n<=373757333) then begin writeln('12899'); halt; end;
if (373757333<n)and(n<=373757335) then begin writeln('12900'); halt; end;
if (373757335<n)and(n<=373757337) then begin writeln('12901'); halt; end;
if (373757337<n)and(n<=373757353) then begin writeln('12902'); halt; end;
if (373757353<n)and(n<=373757355) then begin writeln('12903'); halt; end;
if (373757355<n)and(n<=373757357) then begin writeln('12904'); halt; end;
if (373757357<n)and(n<=373757373) then begin writeln('12905'); halt; end;
if (373757373<n)and(n<=373757375) then begin writeln('12906'); halt; end;
if (373757375<n)and(n<=373757377) then begin writeln('12907'); halt; end;
if (373757377<n)and(n<=373757533) then begin writeln('12908'); halt; end;
if (373757533<n)and(n<=373757535) then begin writeln('12909'); halt; end;
if (373757535<n)and(n<=373757537) then begin writeln('12910'); halt; end;
if (373757537<n)and(n<=373757553) then begin writeln('12911'); halt; end;
if (373757553<n)and(n<=373757555) then begin writeln('12912'); halt; end;
if (373757555<n)and(n<=373757557) then begin writeln('12913'); halt; end;
if (373757557<n)and(n<=373757573) then begin writeln('12914'); halt; end;
if (373757573<n)and(n<=373757575) then begin writeln('12915'); halt; end;
if (373757575<n)and(n<=373757577) then begin writeln('12916'); halt; end;
if (373757577<n)and(n<=373757733) then begin writeln('12917'); halt; end;
if (373757733<n)and(n<=373757735) then begin writeln('12918'); halt; end;
if (373757735<n)and(n<=373757737) then begin writeln('12919'); halt; end;
if (373757737<n)and(n<=373757753) then begin writeln('12920'); halt; end;
if (373757753<n)and(n<=373757755) then begin writeln('12921'); halt; end;
if (373757755<n)and(n<=373757757) then begin writeln('12922'); halt; end;
if (373757757<n)and(n<=373757773) then begin writeln('12923'); halt; end;
if (373757773<n)and(n<=373757775) then begin writeln('12924'); halt; end;
if (373757775<n)and(n<=373757777) then begin writeln('12925'); halt; end;
if (373757777<n)and(n<=373773335) then begin writeln('12926'); halt; end;
if (373773335<n)and(n<=373773353) then begin writeln('12927'); halt; end;
if (373773353<n)and(n<=373773355) then begin writeln('12928'); halt; end;
if (373773355<n)and(n<=373773357) then begin writeln('12929'); halt; end;
if (373773357<n)and(n<=373773375) then begin writeln('12930'); halt; end;
if (373773375<n)and(n<=373773533) then begin writeln('12931'); halt; end;
if (373773533<n)and(n<=373773535) then begin writeln('12932'); halt; end;
if (373773535<n)and(n<=373773537) then begin writeln('12933'); halt; end;
if (373773537<n)and(n<=373773553) then begin writeln('12934'); halt; end;
if (373773553<n)and(n<=373773555) then begin writeln('12935'); halt; end;
if (373773555<n)and(n<=373773557) then begin writeln('12936'); halt; end;
if (373773557<n)and(n<=373773573) then begin writeln('12937'); halt; end;
if (373773573<n)and(n<=373773575) then begin writeln('12938'); halt; end;
if (373773575<n)and(n<=373773577) then begin writeln('12939'); halt; end;
if (373773577<n)and(n<=373773735) then begin writeln('12940'); halt; end;
if (373773735<n)and(n<=373773753) then begin writeln('12941'); halt; end;
if (373773753<n)and(n<=373773755) then begin writeln('12942'); halt; end;
if (373773755<n)and(n<=373773757) then begin writeln('12943'); halt; end;
if (373773757<n)and(n<=373773775) then begin writeln('12944'); halt; end;
if (373773775<n)and(n<=373775333) then begin writeln('12945'); halt; end;
if (373775333<n)and(n<=373775335) then begin writeln('12946'); halt; end;
if (373775335<n)and(n<=373775337) then begin writeln('12947'); halt; end;
if (373775337<n)and(n<=373775353) then begin writeln('12948'); halt; end;
if (373775353<n)and(n<=373775355) then begin writeln('12949'); halt; end;
if (373775355<n)and(n<=373775357) then begin writeln('12950'); halt; end;
if (373775357<n)and(n<=373775373) then begin writeln('12951'); halt; end;
if (373775373<n)and(n<=373775375) then begin writeln('12952'); halt; end;
if (373775375<n)and(n<=373775377) then begin writeln('12953'); halt; end;
if (373775377<n)and(n<=373775533) then begin writeln('12954'); halt; end;
if (373775533<n)and(n<=373775535) then begin writeln('12955'); halt; end;
if (373775535<n)and(n<=373775537) then begin writeln('12956'); halt; end;
if (373775537<n)and(n<=373775553) then begin writeln('12957'); halt; end;
if (373775553<n)and(n<=373775555) then begin writeln('12958'); halt; end;
if (373775555<n)and(n<=373775557) then begin writeln('12959'); halt; end;
if (373775557<n)and(n<=373775573) then begin writeln('12960'); halt; end;
if (373775573<n)and(n<=373775575) then begin writeln('12961'); halt; end;
if (373775575<n)and(n<=373775577) then begin writeln('12962'); halt; end;
if (373775577<n)and(n<=373775733) then begin writeln('12963'); halt; end;
if (373775733<n)and(n<=373775735) then begin writeln('12964'); halt; end;
if (373775735<n)and(n<=373775737) then begin writeln('12965'); halt; end;
if (373775737<n)and(n<=373775753) then begin writeln('12966'); halt; end;
if (373775753<n)and(n<=373775755) then begin writeln('12967'); halt; end;
if (373775755<n)and(n<=373775757) then begin writeln('12968'); halt; end;
if (373775757<n)and(n<=373775773) then begin writeln('12969'); halt; end;
if (373775773<n)and(n<=373775775) then begin writeln('12970'); halt; end;
if (373775775<n)and(n<=373775777) then begin writeln('12971'); halt; end;
if (373775777<n)and(n<=373777335) then begin writeln('12972'); halt; end;
if (373777335<n)and(n<=373777353) then begin writeln('12973'); halt; end;
if (373777353<n)and(n<=373777355) then begin writeln('12974'); halt; end;
if (373777355<n)and(n<=373777357) then begin writeln('12975'); halt; end;
if (373777357<n)and(n<=373777375) then begin writeln('12976'); halt; end;
if (373777375<n)and(n<=373777533) then begin writeln('12977'); halt; end;
if (373777533<n)and(n<=373777535) then begin writeln('12978'); halt; end;
if (373777535<n)and(n<=373777537) then begin writeln('12979'); halt; end;
if (373777537<n)and(n<=373777553) then begin writeln('12980'); halt; end;
if (373777553<n)and(n<=373777555) then begin writeln('12981'); halt; end;
if (373777555<n)and(n<=373777557) then begin writeln('12982'); halt; end;
if (373777557<n)and(n<=373777573) then begin writeln('12983'); halt; end;
if (373777573<n)and(n<=373777575) then begin writeln('12984'); halt; end;
if (373777575<n)and(n<=373777577) then begin writeln('12985'); halt; end;
if (373777577<n)and(n<=373777735) then begin writeln('12986'); halt; end;
if (373777735<n)and(n<=373777753) then begin writeln('12987'); halt; end;
if (373777753<n)and(n<=373777755) then begin writeln('12988'); halt; end;
if (373777755<n)and(n<=373777757) then begin writeln('12989'); halt; end;
if (373777757<n)and(n<=373777775) then begin writeln('12990'); halt; end;
if (373777775<n)and(n<=375333333) then begin writeln('12991'); halt; end;
if (375333333<n)and(n<=375333335) then begin writeln('12992'); halt; end;
if (375333335<n)and(n<=375333337) then begin writeln('12993'); halt; end;
if (375333337<n)and(n<=375333353) then begin writeln('12994'); halt; end;
if (375333353<n)and(n<=375333355) then begin writeln('12995'); halt; end;
if (375333355<n)and(n<=375333357) then begin writeln('12996'); halt; end;
if (375333357<n)and(n<=375333373) then begin writeln('12997'); halt; end;
if (375333373<n)and(n<=375333375) then begin writeln('12998'); halt; end;
if (375333375<n)and(n<=375333377) then begin writeln('12999'); halt; end;
if (375333377<n)and(n<=375333533) then begin writeln('13000'); halt; end;
if (375333533<n)and(n<=375333535) then begin writeln('13001'); halt; end;
if (375333535<n)and(n<=375333537) then begin writeln('13002'); halt; end;
if (375333537<n)and(n<=375333553) then begin writeln('13003'); halt; end;
if (375333553<n)and(n<=375333555) then begin writeln('13004'); halt; end;
if (375333555<n)and(n<=375333557) then begin writeln('13005'); halt; end;
if (375333557<n)and(n<=375333573) then begin writeln('13006'); halt; end;
if (375333573<n)and(n<=375333575) then begin writeln('13007'); halt; end;
if (375333575<n)and(n<=375333577) then begin writeln('13008'); halt; end;
if (375333577<n)and(n<=375333733) then begin writeln('13009'); halt; end;
if (375333733<n)and(n<=375333735) then begin writeln('13010'); halt; end;
if (375333735<n)and(n<=375333737) then begin writeln('13011'); halt; end;
if (375333737<n)and(n<=375333753) then begin writeln('13012'); halt; end;
if (375333753<n)and(n<=375333755) then begin writeln('13013'); halt; end;
if (375333755<n)and(n<=375333757) then begin writeln('13014'); halt; end;
if (375333757<n)and(n<=375333773) then begin writeln('13015'); halt; end;
if (375333773<n)and(n<=375333775) then begin writeln('13016'); halt; end;
if (375333775<n)and(n<=375333777) then begin writeln('13017'); halt; end;
if (375333777<n)and(n<=375335333) then begin writeln('13018'); halt; end;
if (375335333<n)and(n<=375335335) then begin writeln('13019'); halt; end;
if (375335335<n)and(n<=375335337) then begin writeln('13020'); halt; end;
if (375335337<n)and(n<=375335353) then begin writeln('13021'); halt; end;
if (375335353<n)and(n<=375335355) then begin writeln('13022'); halt; end;
if (375335355<n)and(n<=375335357) then begin writeln('13023'); halt; end;
if (375335357<n)and(n<=375335373) then begin writeln('13024'); halt; end;
if (375335373<n)and(n<=375335375) then begin writeln('13025'); halt; end;
if (375335375<n)and(n<=375335377) then begin writeln('13026'); halt; end;
if (375335377<n)and(n<=375335533) then begin writeln('13027'); halt; end;
if (375335533<n)and(n<=375335535) then begin writeln('13028'); halt; end;
if (375335535<n)and(n<=375335537) then begin writeln('13029'); halt; end;
if (375335537<n)and(n<=375335553) then begin writeln('13030'); halt; end;
if (375335553<n)and(n<=375335555) then begin writeln('13031'); halt; end;
if (375335555<n)and(n<=375335557) then begin writeln('13032'); halt; end;
if (375335557<n)and(n<=375335573) then begin writeln('13033'); halt; end;
if (375335573<n)and(n<=375335575) then begin writeln('13034'); halt; end;
if (375335575<n)and(n<=375335577) then begin writeln('13035'); halt; end;
if (375335577<n)and(n<=375335733) then begin writeln('13036'); halt; end;
if (375335733<n)and(n<=375335735) then begin writeln('13037'); halt; end;
if (375335735<n)and(n<=375335737) then begin writeln('13038'); halt; end;
if (375335737<n)and(n<=375335753) then begin writeln('13039'); halt; end;
if (375335753<n)and(n<=375335755) then begin writeln('13040'); halt; end;
if (375335755<n)and(n<=375335757) then begin writeln('13041'); halt; end;
if (375335757<n)and(n<=375335773) then begin writeln('13042'); halt; end;
if (375335773<n)and(n<=375335775) then begin writeln('13043'); halt; end;
if (375335775<n)and(n<=375335777) then begin writeln('13044'); halt; end;
if (375335777<n)and(n<=375337333) then begin writeln('13045'); halt; end;
if (375337333<n)and(n<=375337335) then begin writeln('13046'); halt; end;
if (375337335<n)and(n<=375337337) then begin writeln('13047'); halt; end;
if (375337337<n)and(n<=375337353) then begin writeln('13048'); halt; end;
if (375337353<n)and(n<=375337355) then begin writeln('13049'); halt; end;
if (375337355<n)and(n<=375337357) then begin writeln('13050'); halt; end;
if (375337357<n)and(n<=375337373) then begin writeln('13051'); halt; end;
if (375337373<n)and(n<=375337375) then begin writeln('13052'); halt; end;
if (375337375<n)and(n<=375337377) then begin writeln('13053'); halt; end;
if (375337377<n)and(n<=375337533) then begin writeln('13054'); halt; end;
if (375337533<n)and(n<=375337535) then begin writeln('13055'); halt; end;
if (375337535<n)and(n<=375337537) then begin writeln('13056'); halt; end;
if (375337537<n)and(n<=375337553) then begin writeln('13057'); halt; end;
if (375337553<n)and(n<=375337555) then begin writeln('13058'); halt; end;
if (375337555<n)and(n<=375337557) then begin writeln('13059'); halt; end;
if (375337557<n)and(n<=375337573) then begin writeln('13060'); halt; end;
if (375337573<n)and(n<=375337575) then begin writeln('13061'); halt; end;
if (375337575<n)and(n<=375337577) then begin writeln('13062'); halt; end;
if (375337577<n)and(n<=375337733) then begin writeln('13063'); halt; end;
if (375337733<n)and(n<=375337735) then begin writeln('13064'); halt; end;
if (375337735<n)and(n<=375337737) then begin writeln('13065'); halt; end;
if (375337737<n)and(n<=375337753) then begin writeln('13066'); halt; end;
if (375337753<n)and(n<=375337755) then begin writeln('13067'); halt; end;
if (375337755<n)and(n<=375337757) then begin writeln('13068'); halt; end;
if (375337757<n)and(n<=375337773) then begin writeln('13069'); halt; end;
if (375337773<n)and(n<=375337775) then begin writeln('13070'); halt; end;
if (375337775<n)and(n<=375337777) then begin writeln('13071'); halt; end;
if (375337777<n)and(n<=375353333) then begin writeln('13072'); halt; end;
if (375353333<n)and(n<=375353335) then begin writeln('13073'); halt; end;
if (375353335<n)and(n<=375353337) then begin writeln('13074'); halt; end;
if (375353337<n)and(n<=375353353) then begin writeln('13075'); halt; end;
if (375353353<n)and(n<=375353355) then begin writeln('13076'); halt; end;
if (375353355<n)and(n<=375353357) then begin writeln('13077'); halt; end;
if (375353357<n)and(n<=375353373) then begin writeln('13078'); halt; end;
if (375353373<n)and(n<=375353375) then begin writeln('13079'); halt; end;
if (375353375<n)and(n<=375353377) then begin writeln('13080'); halt; end;
if (375353377<n)and(n<=375353533) then begin writeln('13081'); halt; end;
if (375353533<n)and(n<=375353535) then begin writeln('13082'); halt; end;
if (375353535<n)and(n<=375353537) then begin writeln('13083'); halt; end;
if (375353537<n)and(n<=375353553) then begin writeln('13084'); halt; end;
if (375353553<n)and(n<=375353555) then begin writeln('13085'); halt; end;
if (375353555<n)and(n<=375353557) then begin writeln('13086'); halt; end;
if (375353557<n)and(n<=375353573) then begin writeln('13087'); halt; end;
if (375353573<n)and(n<=375353575) then begin writeln('13088'); halt; end;
if (375353575<n)and(n<=375353577) then begin writeln('13089'); halt; end;
if (375353577<n)and(n<=375353733) then begin writeln('13090'); halt; end;
if (375353733<n)and(n<=375353735) then begin writeln('13091'); halt; end;
if (375353735<n)and(n<=375353737) then begin writeln('13092'); halt; end;
if (375353737<n)and(n<=375353753) then begin writeln('13093'); halt; end;
if (375353753<n)and(n<=375353755) then begin writeln('13094'); halt; end;
if (375353755<n)and(n<=375353757) then begin writeln('13095'); halt; end;
if (375353757<n)and(n<=375353773) then begin writeln('13096'); halt; end;
if (375353773<n)and(n<=375353775) then begin writeln('13097'); halt; end;
if (375353775<n)and(n<=375353777) then begin writeln('13098'); halt; end;
if (375353777<n)and(n<=375355333) then begin writeln('13099'); halt; end;
if (375355333<n)and(n<=375355335) then begin writeln('13100'); halt; end;
if (375355335<n)and(n<=375355337) then begin writeln('13101'); halt; end;
if (375355337<n)and(n<=375355353) then begin writeln('13102'); halt; end;
if (375355353<n)and(n<=375355355) then begin writeln('13103'); halt; end;
if (375355355<n)and(n<=375355357) then begin writeln('13104'); halt; end;
if (375355357<n)and(n<=375355373) then begin writeln('13105'); halt; end;
if (375355373<n)and(n<=375355375) then begin writeln('13106'); halt; end;
if (375355375<n)and(n<=375355377) then begin writeln('13107'); halt; end;
if (375355377<n)and(n<=375355533) then begin writeln('13108'); halt; end;
if (375355533<n)and(n<=375355535) then begin writeln('13109'); halt; end;
if (375355535<n)and(n<=375355537) then begin writeln('13110'); halt; end;
if (375355537<n)and(n<=375355553) then begin writeln('13111'); halt; end;
if (375355553<n)and(n<=375355555) then begin writeln('13112'); halt; end;
if (375355555<n)and(n<=375355557) then begin writeln('13113'); halt; end;
if (375355557<n)and(n<=375355573) then begin writeln('13114'); halt; end;
if (375355573<n)and(n<=375355575) then begin writeln('13115'); halt; end;
if (375355575<n)and(n<=375355577) then begin writeln('13116'); halt; end;
if (375355577<n)and(n<=375355733) then begin writeln('13117'); halt; end;
if (375355733<n)and(n<=375355735) then begin writeln('13118'); halt; end;
if (375355735<n)and(n<=375355737) then begin writeln('13119'); halt; end;
if (375355737<n)and(n<=375355753) then begin writeln('13120'); halt; end;
if (375355753<n)and(n<=375355755) then begin writeln('13121'); halt; end;
if (375355755<n)and(n<=375355757) then begin writeln('13122'); halt; end;
if (375355757<n)and(n<=375355773) then begin writeln('13123'); halt; end;
if (375355773<n)and(n<=375355775) then begin writeln('13124'); halt; end;
if (375355775<n)and(n<=375355777) then begin writeln('13125'); halt; end;
if (375355777<n)and(n<=375357333) then begin writeln('13126'); halt; end;
if (375357333<n)and(n<=375357335) then begin writeln('13127'); halt; end;
if (375357335<n)and(n<=375357337) then begin writeln('13128'); halt; end;
if (375357337<n)and(n<=375357353) then begin writeln('13129'); halt; end;
if (375357353<n)and(n<=375357355) then begin writeln('13130'); halt; end;
if (375357355<n)and(n<=375357357) then begin writeln('13131'); halt; end;
if (375357357<n)and(n<=375357373) then begin writeln('13132'); halt; end;
if (375357373<n)and(n<=375357375) then begin writeln('13133'); halt; end;
if (375357375<n)and(n<=375357377) then begin writeln('13134'); halt; end;
if (375357377<n)and(n<=375357533) then begin writeln('13135'); halt; end;
if (375357533<n)and(n<=375357535) then begin writeln('13136'); halt; end;
if (375357535<n)and(n<=375357537) then begin writeln('13137'); halt; end;
if (375357537<n)and(n<=375357553) then begin writeln('13138'); halt; end;
if (375357553<n)and(n<=375357555) then begin writeln('13139'); halt; end;
if (375357555<n)and(n<=375357557) then begin writeln('13140'); halt; end;
if (375357557<n)and(n<=375357573) then begin writeln('13141'); halt; end;
if (375357573<n)and(n<=375357575) then begin writeln('13142'); halt; end;
if (375357575<n)and(n<=375357577) then begin writeln('13143'); halt; end;
if (375357577<n)and(n<=375357733) then begin writeln('13144'); halt; end;
if (375357733<n)and(n<=375357735) then begin writeln('13145'); halt; end;
if (375357735<n)and(n<=375357737) then begin writeln('13146'); halt; end;
if (375357737<n)and(n<=375357753) then begin writeln('13147'); halt; end;
if (375357753<n)and(n<=375357755) then begin writeln('13148'); halt; end;
if (375357755<n)and(n<=375357757) then begin writeln('13149'); halt; end;
if (375357757<n)and(n<=375357773) then begin writeln('13150'); halt; end;
if (375357773<n)and(n<=375357775) then begin writeln('13151'); halt; end;
if (375357775<n)and(n<=375357777) then begin writeln('13152'); halt; end;
if (375357777<n)and(n<=375373333) then begin writeln('13153'); halt; end;
if (375373333<n)and(n<=375373335) then begin writeln('13154'); halt; end;
if (375373335<n)and(n<=375373337) then begin writeln('13155'); halt; end;
if (375373337<n)and(n<=375373353) then begin writeln('13156'); halt; end;
if (375373353<n)and(n<=375373355) then begin writeln('13157'); halt; end;
if (375373355<n)and(n<=375373357) then begin writeln('13158'); halt; end;
if (375373357<n)and(n<=375373373) then begin writeln('13159'); halt; end;
if (375373373<n)and(n<=375373375) then begin writeln('13160'); halt; end;
if (375373375<n)and(n<=375373377) then begin writeln('13161'); halt; end;
if (375373377<n)and(n<=375373533) then begin writeln('13162'); halt; end;
if (375373533<n)and(n<=375373535) then begin writeln('13163'); halt; end;
if (375373535<n)and(n<=375373537) then begin writeln('13164'); halt; end;
if (375373537<n)and(n<=375373553) then begin writeln('13165'); halt; end;
if (375373553<n)and(n<=375373555) then begin writeln('13166'); halt; end;
if (375373555<n)and(n<=375373557) then begin writeln('13167'); halt; end;
if (375373557<n)and(n<=375373573) then begin writeln('13168'); halt; end;
if (375373573<n)and(n<=375373575) then begin writeln('13169'); halt; end;
if (375373575<n)and(n<=375373577) then begin writeln('13170'); halt; end;
if (375373577<n)and(n<=375373733) then begin writeln('13171'); halt; end;
if (375373733<n)and(n<=375373735) then begin writeln('13172'); halt; end;
if (375373735<n)and(n<=375373737) then begin writeln('13173'); halt; end;
if (375373737<n)and(n<=375373753) then begin writeln('13174'); halt; end;
if (375373753<n)and(n<=375373755) then begin writeln('13175'); halt; end;
if (375373755<n)and(n<=375373757) then begin writeln('13176'); halt; end;
if (375373757<n)and(n<=375373773) then begin writeln('13177'); halt; end;
if (375373773<n)and(n<=375373775) then begin writeln('13178'); halt; end;
if (375373775<n)and(n<=375373777) then begin writeln('13179'); halt; end;
if (375373777<n)and(n<=375375333) then begin writeln('13180'); halt; end;
if (375375333<n)and(n<=375375335) then begin writeln('13181'); halt; end;
if (375375335<n)and(n<=375375337) then begin writeln('13182'); halt; end;
if (375375337<n)and(n<=375375353) then begin writeln('13183'); halt; end;
if (375375353<n)and(n<=375375355) then begin writeln('13184'); halt; end;
if (375375355<n)and(n<=375375357) then begin writeln('13185'); halt; end;
if (375375357<n)and(n<=375375373) then begin writeln('13186'); halt; end;
if (375375373<n)and(n<=375375375) then begin writeln('13187'); halt; end;
if (375375375<n)and(n<=375375377) then begin writeln('13188'); halt; end;
if (375375377<n)and(n<=375375533) then begin writeln('13189'); halt; end;
if (375375533<n)and(n<=375375535) then begin writeln('13190'); halt; end;
if (375375535<n)and(n<=375375537) then begin writeln('13191'); halt; end;
if (375375537<n)and(n<=375375553) then begin writeln('13192'); halt; end;
if (375375553<n)and(n<=375375555) then begin writeln('13193'); halt; end;
if (375375555<n)and(n<=375375557) then begin writeln('13194'); halt; end;
if (375375557<n)and(n<=375375573) then begin writeln('13195'); halt; end;
if (375375573<n)and(n<=375375575) then begin writeln('13196'); halt; end;
if (375375575<n)and(n<=375375577) then begin writeln('13197'); halt; end;
if (375375577<n)and(n<=375375733) then begin writeln('13198'); halt; end;
if (375375733<n)and(n<=375375735) then begin writeln('13199'); halt; end;
if (375375735<n)and(n<=375375737) then begin writeln('13200'); halt; end;
if (375375737<n)and(n<=375375753) then begin writeln('13201'); halt; end;
if (375375753<n)and(n<=375375755) then begin writeln('13202'); halt; end;
if (375375755<n)and(n<=375375757) then begin writeln('13203'); halt; end;
if (375375757<n)and(n<=375375773) then begin writeln('13204'); halt; end;
if (375375773<n)and(n<=375375775) then begin writeln('13205'); halt; end;
if (375375775<n)and(n<=375375777) then begin writeln('13206'); halt; end;
if (375375777<n)and(n<=375377333) then begin writeln('13207'); halt; end;
if (375377333<n)and(n<=375377335) then begin writeln('13208'); halt; end;
if (375377335<n)and(n<=375377337) then begin writeln('13209'); halt; end;
if (375377337<n)and(n<=375377353) then begin writeln('13210'); halt; end;
if (375377353<n)and(n<=375377355) then begin writeln('13211'); halt; end;
if (375377355<n)and(n<=375377357) then begin writeln('13212'); halt; end;
if (375377357<n)and(n<=375377373) then begin writeln('13213'); halt; end;
if (375377373<n)and(n<=375377375) then begin writeln('13214'); halt; end;
if (375377375<n)and(n<=375377377) then begin writeln('13215'); halt; end;
if (375377377<n)and(n<=375377533) then begin writeln('13216'); halt; end;
if (375377533<n)and(n<=375377535) then begin writeln('13217'); halt; end;
if (375377535<n)and(n<=375377537) then begin writeln('13218'); halt; end;
if (375377537<n)and(n<=375377553) then begin writeln('13219'); halt; end;
if (375377553<n)and(n<=375377555) then begin writeln('13220'); halt; end;
if (375377555<n)and(n<=375377557) then begin writeln('13221'); halt; end;
if (375377557<n)and(n<=375377573) then begin writeln('13222'); halt; end;
if (375377573<n)and(n<=375377575) then begin writeln('13223'); halt; end;
if (375377575<n)and(n<=375377577) then begin writeln('13224'); halt; end;
if (375377577<n)and(n<=375377733) then begin writeln('13225'); halt; end;
if (375377733<n)and(n<=375377735) then begin writeln('13226'); halt; end;
if (375377735<n)and(n<=375377737) then begin writeln('13227'); halt; end;
if (375377737<n)and(n<=375377753) then begin writeln('13228'); halt; end;
if (375377753<n)and(n<=375377755) then begin writeln('13229'); halt; end;
if (375377755<n)and(n<=375377757) then begin writeln('13230'); halt; end;
if (375377757<n)and(n<=375377773) then begin writeln('13231'); halt; end;
if (375377773<n)and(n<=375377775) then begin writeln('13232'); halt; end;
if (375377775<n)and(n<=375377777) then begin writeln('13233'); halt; end;
if (375377777<n)and(n<=375533333) then begin writeln('13234'); halt; end;
if (375533333<n)and(n<=375533335) then begin writeln('13235'); halt; end;
if (375533335<n)and(n<=375533337) then begin writeln('13236'); halt; end;
if (375533337<n)and(n<=375533353) then begin writeln('13237'); halt; end;
if (375533353<n)and(n<=375533355) then begin writeln('13238'); halt; end;
if (375533355<n)and(n<=375533357) then begin writeln('13239'); halt; end;
if (375533357<n)and(n<=375533373) then begin writeln('13240'); halt; end;
if (375533373<n)and(n<=375533375) then begin writeln('13241'); halt; end;
if (375533375<n)and(n<=375533377) then begin writeln('13242'); halt; end;
if (375533377<n)and(n<=375533533) then begin writeln('13243'); halt; end;
if (375533533<n)and(n<=375533535) then begin writeln('13244'); halt; end;
if (375533535<n)and(n<=375533537) then begin writeln('13245'); halt; end;
if (375533537<n)and(n<=375533553) then begin writeln('13246'); halt; end;
if (375533553<n)and(n<=375533555) then begin writeln('13247'); halt; end;
if (375533555<n)and(n<=375533557) then begin writeln('13248'); halt; end;
if (375533557<n)and(n<=375533573) then begin writeln('13249'); halt; end;
if (375533573<n)and(n<=375533575) then begin writeln('13250'); halt; end;
if (375533575<n)and(n<=375533577) then begin writeln('13251'); halt; end;
if (375533577<n)and(n<=375533733) then begin writeln('13252'); halt; end;
if (375533733<n)and(n<=375533735) then begin writeln('13253'); halt; end;
if (375533735<n)and(n<=375533737) then begin writeln('13254'); halt; end;
if (375533737<n)and(n<=375533753) then begin writeln('13255'); halt; end;
if (375533753<n)and(n<=375533755) then begin writeln('13256'); halt; end;
if (375533755<n)and(n<=375533757) then begin writeln('13257'); halt; end;
if (375533757<n)and(n<=375533773) then begin writeln('13258'); halt; end;
if (375533773<n)and(n<=375533775) then begin writeln('13259'); halt; end;
if (375533775<n)and(n<=375533777) then begin writeln('13260'); halt; end;
if (375533777<n)and(n<=375535333) then begin writeln('13261'); halt; end;
if (375535333<n)and(n<=375535335) then begin writeln('13262'); halt; end;
if (375535335<n)and(n<=375535337) then begin writeln('13263'); halt; end;
if (375535337<n)and(n<=375535353) then begin writeln('13264'); halt; end;
if (375535353<n)and(n<=375535355) then begin writeln('13265'); halt; end;
if (375535355<n)and(n<=375535357) then begin writeln('13266'); halt; end;
if (375535357<n)and(n<=375535373) then begin writeln('13267'); halt; end;
if (375535373<n)and(n<=375535375) then begin writeln('13268'); halt; end;
if (375535375<n)and(n<=375535377) then begin writeln('13269'); halt; end;
if (375535377<n)and(n<=375535533) then begin writeln('13270'); halt; end;
if (375535533<n)and(n<=375535535) then begin writeln('13271'); halt; end;
if (375535535<n)and(n<=375535537) then begin writeln('13272'); halt; end;
if (375535537<n)and(n<=375535553) then begin writeln('13273'); halt; end;
if (375535553<n)and(n<=375535555) then begin writeln('13274'); halt; end;
if (375535555<n)and(n<=375535557) then begin writeln('13275'); halt; end;
if (375535557<n)and(n<=375535573) then begin writeln('13276'); halt; end;
if (375535573<n)and(n<=375535575) then begin writeln('13277'); halt; end;
if (375535575<n)and(n<=375535577) then begin writeln('13278'); halt; end;
if (375535577<n)and(n<=375535733) then begin writeln('13279'); halt; end;
if (375535733<n)and(n<=375535735) then begin writeln('13280'); halt; end;
if (375535735<n)and(n<=375535737) then begin writeln('13281'); halt; end;
if (375535737<n)and(n<=375535753) then begin writeln('13282'); halt; end;
if (375535753<n)and(n<=375535755) then begin writeln('13283'); halt; end;
if (375535755<n)and(n<=375535757) then begin writeln('13284'); halt; end;
if (375535757<n)and(n<=375535773) then begin writeln('13285'); halt; end;
if (375535773<n)and(n<=375535775) then begin writeln('13286'); halt; end;
if (375535775<n)and(n<=375535777) then begin writeln('13287'); halt; end;
if (375535777<n)and(n<=375537333) then begin writeln('13288'); halt; end;
if (375537333<n)and(n<=375537335) then begin writeln('13289'); halt; end;
if (375537335<n)and(n<=375537337) then begin writeln('13290'); halt; end;
if (375537337<n)and(n<=375537353) then begin writeln('13291'); halt; end;
if (375537353<n)and(n<=375537355) then begin writeln('13292'); halt; end;
if (375537355<n)and(n<=375537357) then begin writeln('13293'); halt; end;
if (375537357<n)and(n<=375537373) then begin writeln('13294'); halt; end;
if (375537373<n)and(n<=375537375) then begin writeln('13295'); halt; end;
if (375537375<n)and(n<=375537377) then begin writeln('13296'); halt; end;
if (375537377<n)and(n<=375537533) then begin writeln('13297'); halt; end;
if (375537533<n)and(n<=375537535) then begin writeln('13298'); halt; end;
if (375537535<n)and(n<=375537537) then begin writeln('13299'); halt; end;
if (375537537<n)and(n<=375537553) then begin writeln('13300'); halt; end;
if (375537553<n)and(n<=375537555) then begin writeln('13301'); halt; end;
if (375537555<n)and(n<=375537557) then begin writeln('13302'); halt; end;
if (375537557<n)and(n<=375537573) then begin writeln('13303'); halt; end;
if (375537573<n)and(n<=375537575) then begin writeln('13304'); halt; end;
if (375537575<n)and(n<=375537577) then begin writeln('13305'); halt; end;
if (375537577<n)and(n<=375537733) then begin writeln('13306'); halt; end;
if (375537733<n)and(n<=375537735) then begin writeln('13307'); halt; end;
if (375537735<n)and(n<=375537737) then begin writeln('13308'); halt; end;
if (375537737<n)and(n<=375537753) then begin writeln('13309'); halt; end;
if (375537753<n)and(n<=375537755) then begin writeln('13310'); halt; end;
if (375537755<n)and(n<=375537757) then begin writeln('13311'); halt; end;
if (375537757<n)and(n<=375537773) then begin writeln('13312'); halt; end;
if (375537773<n)and(n<=375537775) then begin writeln('13313'); halt; end;
if (375537775<n)and(n<=375537777) then begin writeln('13314'); halt; end;
if (375537777<n)and(n<=375553333) then begin writeln('13315'); halt; end;
if (375553333<n)and(n<=375553335) then begin writeln('13316'); halt; end;
if (375553335<n)and(n<=375553337) then begin writeln('13317'); halt; end;
if (375553337<n)and(n<=375553353) then begin writeln('13318'); halt; end;
if (375553353<n)and(n<=375553355) then begin writeln('13319'); halt; end;
if (375553355<n)and(n<=375553357) then begin writeln('13320'); halt; end;
if (375553357<n)and(n<=375553373) then begin writeln('13321'); halt; end;
if (375553373<n)and(n<=375553375) then begin writeln('13322'); halt; end;
if (375553375<n)and(n<=375553377) then begin writeln('13323'); halt; end;
if (375553377<n)and(n<=375553533) then begin writeln('13324'); halt; end;
if (375553533<n)and(n<=375553535) then begin writeln('13325'); halt; end;
if (375553535<n)and(n<=375553537) then begin writeln('13326'); halt; end;
if (375553537<n)and(n<=375553553) then begin writeln('13327'); halt; end;
if (375553553<n)and(n<=375553555) then begin writeln('13328'); halt; end;
if (375553555<n)and(n<=375553557) then begin writeln('13329'); halt; end;
if (375553557<n)and(n<=375553573) then begin writeln('13330'); halt; end;
if (375553573<n)and(n<=375553575) then begin writeln('13331'); halt; end;
if (375553575<n)and(n<=375553577) then begin writeln('13332'); halt; end;
if (375553577<n)and(n<=375553733) then begin writeln('13333'); halt; end;
if (375553733<n)and(n<=375553735) then begin writeln('13334'); halt; end;
if (375553735<n)and(n<=375553737) then begin writeln('13335'); halt; end;
if (375553737<n)and(n<=375553753) then begin writeln('13336'); halt; end;
if (375553753<n)and(n<=375553755) then begin writeln('13337'); halt; end;
if (375553755<n)and(n<=375553757) then begin writeln('13338'); halt; end;
if (375553757<n)and(n<=375553773) then begin writeln('13339'); halt; end;
if (375553773<n)and(n<=375553775) then begin writeln('13340'); halt; end;
if (375553775<n)and(n<=375553777) then begin writeln('13341'); halt; end;
if (375553777<n)and(n<=375555333) then begin writeln('13342'); halt; end;
if (375555333<n)and(n<=375555335) then begin writeln('13343'); halt; end;
if (375555335<n)and(n<=375555337) then begin writeln('13344'); halt; end;
if (375555337<n)and(n<=375555353) then begin writeln('13345'); halt; end;
if (375555353<n)and(n<=375555355) then begin writeln('13346'); halt; end;
if (375555355<n)and(n<=375555357) then begin writeln('13347'); halt; end;
if (375555357<n)and(n<=375555373) then begin writeln('13348'); halt; end;
if (375555373<n)and(n<=375555375) then begin writeln('13349'); halt; end;
if (375555375<n)and(n<=375555377) then begin writeln('13350'); halt; end;
if (375555377<n)and(n<=375555533) then begin writeln('13351'); halt; end;
if (375555533<n)and(n<=375555535) then begin writeln('13352'); halt; end;
if (375555535<n)and(n<=375555537) then begin writeln('13353'); halt; end;
if (375555537<n)and(n<=375555553) then begin writeln('13354'); halt; end;
if (375555553<n)and(n<=375555555) then begin writeln('13355'); halt; end;
if (375555555<n)and(n<=375555557) then begin writeln('13356'); halt; end;
if (375555557<n)and(n<=375555573) then begin writeln('13357'); halt; end;
if (375555573<n)and(n<=375555575) then begin writeln('13358'); halt; end;
if (375555575<n)and(n<=375555577) then begin writeln('13359'); halt; end;
if (375555577<n)and(n<=375555733) then begin writeln('13360'); halt; end;
if (375555733<n)and(n<=375555735) then begin writeln('13361'); halt; end;
if (375555735<n)and(n<=375555737) then begin writeln('13362'); halt; end;
if (375555737<n)and(n<=375555753) then begin writeln('13363'); halt; end;
if (375555753<n)and(n<=375555755) then begin writeln('13364'); halt; end;
if (375555755<n)and(n<=375555757) then begin writeln('13365'); halt; end;
if (375555757<n)and(n<=375555773) then begin writeln('13366'); halt; end;
if (375555773<n)and(n<=375555775) then begin writeln('13367'); halt; end;
if (375555775<n)and(n<=375555777) then begin writeln('13368'); halt; end;
if (375555777<n)and(n<=375557333) then begin writeln('13369'); halt; end;
if (375557333<n)and(n<=375557335) then begin writeln('13370'); halt; end;
if (375557335<n)and(n<=375557337) then begin writeln('13371'); halt; end;
if (375557337<n)and(n<=375557353) then begin writeln('13372'); halt; end;
if (375557353<n)and(n<=375557355) then begin writeln('13373'); halt; end;
if (375557355<n)and(n<=375557357) then begin writeln('13374'); halt; end;
if (375557357<n)and(n<=375557373) then begin writeln('13375'); halt; end;
if (375557373<n)and(n<=375557375) then begin writeln('13376'); halt; end;
if (375557375<n)and(n<=375557377) then begin writeln('13377'); halt; end;
if (375557377<n)and(n<=375557533) then begin writeln('13378'); halt; end;
if (375557533<n)and(n<=375557535) then begin writeln('13379'); halt; end;
if (375557535<n)and(n<=375557537) then begin writeln('13380'); halt; end;
if (375557537<n)and(n<=375557553) then begin writeln('13381'); halt; end;
if (375557553<n)and(n<=375557555) then begin writeln('13382'); halt; end;
if (375557555<n)and(n<=375557557) then begin writeln('13383'); halt; end;
if (375557557<n)and(n<=375557573) then begin writeln('13384'); halt; end;
if (375557573<n)and(n<=375557575) then begin writeln('13385'); halt; end;
if (375557575<n)and(n<=375557577) then begin writeln('13386'); halt; end;
if (375557577<n)and(n<=375557733) then begin writeln('13387'); halt; end;
if (375557733<n)and(n<=375557735) then begin writeln('13388'); halt; end;
if (375557735<n)and(n<=375557737) then begin writeln('13389'); halt; end;
if (375557737<n)and(n<=375557753) then begin writeln('13390'); halt; end;
if (375557753<n)and(n<=375557755) then begin writeln('13391'); halt; end;
if (375557755<n)and(n<=375557757) then begin writeln('13392'); halt; end;
if (375557757<n)and(n<=375557773) then begin writeln('13393'); halt; end;
if (375557773<n)and(n<=375557775) then begin writeln('13394'); halt; end;
if (375557775<n)and(n<=375557777) then begin writeln('13395'); halt; end;
if (375557777<n)and(n<=375573333) then begin writeln('13396'); halt; end;
if (375573333<n)and(n<=375573335) then begin writeln('13397'); halt; end;
if (375573335<n)and(n<=375573337) then begin writeln('13398'); halt; end;
if (375573337<n)and(n<=375573353) then begin writeln('13399'); halt; end;
if (375573353<n)and(n<=375573355) then begin writeln('13400'); halt; end;
if (375573355<n)and(n<=375573357) then begin writeln('13401'); halt; end;
if (375573357<n)and(n<=375573373) then begin writeln('13402'); halt; end;
if (375573373<n)and(n<=375573375) then begin writeln('13403'); halt; end;
if (375573375<n)and(n<=375573377) then begin writeln('13404'); halt; end;
if (375573377<n)and(n<=375573533) then begin writeln('13405'); halt; end;
if (375573533<n)and(n<=375573535) then begin writeln('13406'); halt; end;
if (375573535<n)and(n<=375573537) then begin writeln('13407'); halt; end;
if (375573537<n)and(n<=375573553) then begin writeln('13408'); halt; end;
if (375573553<n)and(n<=375573555) then begin writeln('13409'); halt; end;
if (375573555<n)and(n<=375573557) then begin writeln('13410'); halt; end;
if (375573557<n)and(n<=375573573) then begin writeln('13411'); halt; end;
if (375573573<n)and(n<=375573575) then begin writeln('13412'); halt; end;
if (375573575<n)and(n<=375573577) then begin writeln('13413'); halt; end;
if (375573577<n)and(n<=375573733) then begin writeln('13414'); halt; end;
if (375573733<n)and(n<=375573735) then begin writeln('13415'); halt; end;
if (375573735<n)and(n<=375573737) then begin writeln('13416'); halt; end;
if (375573737<n)and(n<=375573753) then begin writeln('13417'); halt; end;
if (375573753<n)and(n<=375573755) then begin writeln('13418'); halt; end;
if (375573755<n)and(n<=375573757) then begin writeln('13419'); halt; end;
if (375573757<n)and(n<=375573773) then begin writeln('13420'); halt; end;
if (375573773<n)and(n<=375573775) then begin writeln('13421'); halt; end;
if (375573775<n)and(n<=375573777) then begin writeln('13422'); halt; end;
if (375573777<n)and(n<=375575333) then begin writeln('13423'); halt; end;
if (375575333<n)and(n<=375575335) then begin writeln('13424'); halt; end;
if (375575335<n)and(n<=375575337) then begin writeln('13425'); halt; end;
if (375575337<n)and(n<=375575353) then begin writeln('13426'); halt; end;
if (375575353<n)and(n<=375575355) then begin writeln('13427'); halt; end;
if (375575355<n)and(n<=375575357) then begin writeln('13428'); halt; end;
if (375575357<n)and(n<=375575373) then begin writeln('13429'); halt; end;
if (375575373<n)and(n<=375575375) then begin writeln('13430'); halt; end;
if (375575375<n)and(n<=375575377) then begin writeln('13431'); halt; end;
if (375575377<n)and(n<=375575533) then begin writeln('13432'); halt; end;
if (375575533<n)and(n<=375575535) then begin writeln('13433'); halt; end;
if (375575535<n)and(n<=375575537) then begin writeln('13434'); halt; end;
if (375575537<n)and(n<=375575553) then begin writeln('13435'); halt; end;
if (375575553<n)and(n<=375575555) then begin writeln('13436'); halt; end;
if (375575555<n)and(n<=375575557) then begin writeln('13437'); halt; end;
if (375575557<n)and(n<=375575573) then begin writeln('13438'); halt; end;
if (375575573<n)and(n<=375575575) then begin writeln('13439'); halt; end;
if (375575575<n)and(n<=375575577) then begin writeln('13440'); halt; end;
if (375575577<n)and(n<=375575733) then begin writeln('13441'); halt; end;
if (375575733<n)and(n<=375575735) then begin writeln('13442'); halt; end;
if (375575735<n)and(n<=375575737) then begin writeln('13443'); halt; end;
if (375575737<n)and(n<=375575753) then begin writeln('13444'); halt; end;
if (375575753<n)and(n<=375575755) then begin writeln('13445'); halt; end;
if (375575755<n)and(n<=375575757) then begin writeln('13446'); halt; end;
if (375575757<n)and(n<=375575773) then begin writeln('13447'); halt; end;
if (375575773<n)and(n<=375575775) then begin writeln('13448'); halt; end;
if (375575775<n)and(n<=375575777) then begin writeln('13449'); halt; end;
if (375575777<n)and(n<=375577333) then begin writeln('13450'); halt; end;
if (375577333<n)and(n<=375577335) then begin writeln('13451'); halt; end;
if (375577335<n)and(n<=375577337) then begin writeln('13452'); halt; end;
if (375577337<n)and(n<=375577353) then begin writeln('13453'); halt; end;
if (375577353<n)and(n<=375577355) then begin writeln('13454'); halt; end;
if (375577355<n)and(n<=375577357) then begin writeln('13455'); halt; end;
if (375577357<n)and(n<=375577373) then begin writeln('13456'); halt; end;
if (375577373<n)and(n<=375577375) then begin writeln('13457'); halt; end;
if (375577375<n)and(n<=375577377) then begin writeln('13458'); halt; end;
if (375577377<n)and(n<=375577533) then begin writeln('13459'); halt; end;
if (375577533<n)and(n<=375577535) then begin writeln('13460'); halt; end;
if (375577535<n)and(n<=375577537) then begin writeln('13461'); halt; end;
if (375577537<n)and(n<=375577553) then begin writeln('13462'); halt; end;
if (375577553<n)and(n<=375577555) then begin writeln('13463'); halt; end;
if (375577555<n)and(n<=375577557) then begin writeln('13464'); halt; end;
if (375577557<n)and(n<=375577573) then begin writeln('13465'); halt; end;
if (375577573<n)and(n<=375577575) then begin writeln('13466'); halt; end;
if (375577575<n)and(n<=375577577) then begin writeln('13467'); halt; end;
if (375577577<n)and(n<=375577733) then begin writeln('13468'); halt; end;
if (375577733<n)and(n<=375577735) then begin writeln('13469'); halt; end;
if (375577735<n)and(n<=375577737) then begin writeln('13470'); halt; end;
if (375577737<n)and(n<=375577753) then begin writeln('13471'); halt; end;
if (375577753<n)and(n<=375577755) then begin writeln('13472'); halt; end;
if (375577755<n)and(n<=375577757) then begin writeln('13473'); halt; end;
if (375577757<n)and(n<=375577773) then begin writeln('13474'); halt; end;
if (375577773<n)and(n<=375577775) then begin writeln('13475'); halt; end;
if (375577775<n)and(n<=375577777) then begin writeln('13476'); halt; end;
if (375577777<n)and(n<=375733333) then begin writeln('13477'); halt; end;
if (375733333<n)and(n<=375733335) then begin writeln('13478'); halt; end;
if (375733335<n)and(n<=375733337) then begin writeln('13479'); halt; end;
if (375733337<n)and(n<=375733353) then begin writeln('13480'); halt; end;
if (375733353<n)and(n<=375733355) then begin writeln('13481'); halt; end;
if (375733355<n)and(n<=375733357) then begin writeln('13482'); halt; end;
if (375733357<n)and(n<=375733373) then begin writeln('13483'); halt; end;
if (375733373<n)and(n<=375733375) then begin writeln('13484'); halt; end;
if (375733375<n)and(n<=375733377) then begin writeln('13485'); halt; end;
if (375733377<n)and(n<=375733533) then begin writeln('13486'); halt; end;
if (375733533<n)and(n<=375733535) then begin writeln('13487'); halt; end;
if (375733535<n)and(n<=375733537) then begin writeln('13488'); halt; end;
if (375733537<n)and(n<=375733553) then begin writeln('13489'); halt; end;
if (375733553<n)and(n<=375733555) then begin writeln('13490'); halt; end;
if (375733555<n)and(n<=375733557) then begin writeln('13491'); halt; end;
if (375733557<n)and(n<=375733573) then begin writeln('13492'); halt; end;
if (375733573<n)and(n<=375733575) then begin writeln('13493'); halt; end;
if (375733575<n)and(n<=375733577) then begin writeln('13494'); halt; end;
if (375733577<n)and(n<=375733733) then begin writeln('13495'); halt; end;
if (375733733<n)and(n<=375733735) then begin writeln('13496'); halt; end;
if (375733735<n)and(n<=375733737) then begin writeln('13497'); halt; end;
if (375733737<n)and(n<=375733753) then begin writeln('13498'); halt; end;
if (375733753<n)and(n<=375733755) then begin writeln('13499'); halt; end;
if (375733755<n)and(n<=375733757) then begin writeln('13500'); halt; end;
if (375733757<n)and(n<=375733773) then begin writeln('13501'); halt; end;
if (375733773<n)and(n<=375733775) then begin writeln('13502'); halt; end;
if (375733775<n)and(n<=375733777) then begin writeln('13503'); halt; end;
if (375733777<n)and(n<=375735333) then begin writeln('13504'); halt; end;
if (375735333<n)and(n<=375735335) then begin writeln('13505'); halt; end;
if (375735335<n)and(n<=375735337) then begin writeln('13506'); halt; end;
if (375735337<n)and(n<=375735353) then begin writeln('13507'); halt; end;
if (375735353<n)and(n<=375735355) then begin writeln('13508'); halt; end;
if (375735355<n)and(n<=375735357) then begin writeln('13509'); halt; end;
if (375735357<n)and(n<=375735373) then begin writeln('13510'); halt; end;
if (375735373<n)and(n<=375735375) then begin writeln('13511'); halt; end;
if (375735375<n)and(n<=375735377) then begin writeln('13512'); halt; end;
if (375735377<n)and(n<=375735533) then begin writeln('13513'); halt; end;
if (375735533<n)and(n<=375735535) then begin writeln('13514'); halt; end;
if (375735535<n)and(n<=375735537) then begin writeln('13515'); halt; end;
if (375735537<n)and(n<=375735553) then begin writeln('13516'); halt; end;
if (375735553<n)and(n<=375735555) then begin writeln('13517'); halt; end;
if (375735555<n)and(n<=375735557) then begin writeln('13518'); halt; end;
if (375735557<n)and(n<=375735573) then begin writeln('13519'); halt; end;
if (375735573<n)and(n<=375735575) then begin writeln('13520'); halt; end;
if (375735575<n)and(n<=375735577) then begin writeln('13521'); halt; end;
if (375735577<n)and(n<=375735733) then begin writeln('13522'); halt; end;
if (375735733<n)and(n<=375735735) then begin writeln('13523'); halt; end;
if (375735735<n)and(n<=375735737) then begin writeln('13524'); halt; end;
if (375735737<n)and(n<=375735753) then begin writeln('13525'); halt; end;
if (375735753<n)and(n<=375735755) then begin writeln('13526'); halt; end;
if (375735755<n)and(n<=375735757) then begin writeln('13527'); halt; end;
if (375735757<n)and(n<=375735773) then begin writeln('13528'); halt; end;
if (375735773<n)and(n<=375735775) then begin writeln('13529'); halt; end;
if (375735775<n)and(n<=375735777) then begin writeln('13530'); halt; end;
if (375735777<n)and(n<=375737333) then begin writeln('13531'); halt; end;
if (375737333<n)and(n<=375737335) then begin writeln('13532'); halt; end;
if (375737335<n)and(n<=375737337) then begin writeln('13533'); halt; end;
if (375737337<n)and(n<=375737353) then begin writeln('13534'); halt; end;
if (375737353<n)and(n<=375737355) then begin writeln('13535'); halt; end;
if (375737355<n)and(n<=375737357) then begin writeln('13536'); halt; end;
if (375737357<n)and(n<=375737373) then begin writeln('13537'); halt; end;
if (375737373<n)and(n<=375737375) then begin writeln('13538'); halt; end;
if (375737375<n)and(n<=375737377) then begin writeln('13539'); halt; end;
if (375737377<n)and(n<=375737533) then begin writeln('13540'); halt; end;
if (375737533<n)and(n<=375737535) then begin writeln('13541'); halt; end;
if (375737535<n)and(n<=375737537) then begin writeln('13542'); halt; end;
if (375737537<n)and(n<=375737553) then begin writeln('13543'); halt; end;
if (375737553<n)and(n<=375737555) then begin writeln('13544'); halt; end;
if (375737555<n)and(n<=375737557) then begin writeln('13545'); halt; end;
if (375737557<n)and(n<=375737573) then begin writeln('13546'); halt; end;
if (375737573<n)and(n<=375737575) then begin writeln('13547'); halt; end;
if (375737575<n)and(n<=375737577) then begin writeln('13548'); halt; end;
if (375737577<n)and(n<=375737733) then begin writeln('13549'); halt; end;
if (375737733<n)and(n<=375737735) then begin writeln('13550'); halt; end;
if (375737735<n)and(n<=375737737) then begin writeln('13551'); halt; end;
if (375737737<n)and(n<=375737753) then begin writeln('13552'); halt; end;
if (375737753<n)and(n<=375737755) then begin writeln('13553'); halt; end;
if (375737755<n)and(n<=375737757) then begin writeln('13554'); halt; end;
if (375737757<n)and(n<=375737773) then begin writeln('13555'); halt; end;
if (375737773<n)and(n<=375737775) then begin writeln('13556'); halt; end;
if (375737775<n)and(n<=375737777) then begin writeln('13557'); halt; end;
if (375737777<n)and(n<=375753333) then begin writeln('13558'); halt; end;
if (375753333<n)and(n<=375753335) then begin writeln('13559'); halt; end;
if (375753335<n)and(n<=375753337) then begin writeln('13560'); halt; end;
if (375753337<n)and(n<=375753353) then begin writeln('13561'); halt; end;
if (375753353<n)and(n<=375753355) then begin writeln('13562'); halt; end;
if (375753355<n)and(n<=375753357) then begin writeln('13563'); halt; end;
if (375753357<n)and(n<=375753373) then begin writeln('13564'); halt; end;
if (375753373<n)and(n<=375753375) then begin writeln('13565'); halt; end;
if (375753375<n)and(n<=375753377) then begin writeln('13566'); halt; end;
if (375753377<n)and(n<=375753533) then begin writeln('13567'); halt; end;
if (375753533<n)and(n<=375753535) then begin writeln('13568'); halt; end;
if (375753535<n)and(n<=375753537) then begin writeln('13569'); halt; end;
if (375753537<n)and(n<=375753553) then begin writeln('13570'); halt; end;
if (375753553<n)and(n<=375753555) then begin writeln('13571'); halt; end;
if (375753555<n)and(n<=375753557) then begin writeln('13572'); halt; end;
if (375753557<n)and(n<=375753573) then begin writeln('13573'); halt; end;
if (375753573<n)and(n<=375753575) then begin writeln('13574'); halt; end;
if (375753575<n)and(n<=375753577) then begin writeln('13575'); halt; end;
if (375753577<n)and(n<=375753733) then begin writeln('13576'); halt; end;
if (375753733<n)and(n<=375753735) then begin writeln('13577'); halt; end;
if (375753735<n)and(n<=375753737) then begin writeln('13578'); halt; end;
if (375753737<n)and(n<=375753753) then begin writeln('13579'); halt; end;
if (375753753<n)and(n<=375753755) then begin writeln('13580'); halt; end;
if (375753755<n)and(n<=375753757) then begin writeln('13581'); halt; end;
if (375753757<n)and(n<=375753773) then begin writeln('13582'); halt; end;
if (375753773<n)and(n<=375753775) then begin writeln('13583'); halt; end;
if (375753775<n)and(n<=375753777) then begin writeln('13584'); halt; end;
if (375753777<n)and(n<=375755333) then begin writeln('13585'); halt; end;
if (375755333<n)and(n<=375755335) then begin writeln('13586'); halt; end;
if (375755335<n)and(n<=375755337) then begin writeln('13587'); halt; end;
if (375755337<n)and(n<=375755353) then begin writeln('13588'); halt; end;
if (375755353<n)and(n<=375755355) then begin writeln('13589'); halt; end;
if (375755355<n)and(n<=375755357) then begin writeln('13590'); halt; end;
if (375755357<n)and(n<=375755373) then begin writeln('13591'); halt; end;
if (375755373<n)and(n<=375755375) then begin writeln('13592'); halt; end;
if (375755375<n)and(n<=375755377) then begin writeln('13593'); halt; end;
if (375755377<n)and(n<=375755533) then begin writeln('13594'); halt; end;
if (375755533<n)and(n<=375755535) then begin writeln('13595'); halt; end;
if (375755535<n)and(n<=375755537) then begin writeln('13596'); halt; end;
if (375755537<n)and(n<=375755553) then begin writeln('13597'); halt; end;
if (375755553<n)and(n<=375755555) then begin writeln('13598'); halt; end;
if (375755555<n)and(n<=375755557) then begin writeln('13599'); halt; end;
if (375755557<n)and(n<=375755573) then begin writeln('13600'); halt; end;
if (375755573<n)and(n<=375755575) then begin writeln('13601'); halt; end;
if (375755575<n)and(n<=375755577) then begin writeln('13602'); halt; end;
if (375755577<n)and(n<=375755733) then begin writeln('13603'); halt; end;
if (375755733<n)and(n<=375755735) then begin writeln('13604'); halt; end;
if (375755735<n)and(n<=375755737) then begin writeln('13605'); halt; end;
if (375755737<n)and(n<=375755753) then begin writeln('13606'); halt; end;
if (375755753<n)and(n<=375755755) then begin writeln('13607'); halt; end;
if (375755755<n)and(n<=375755757) then begin writeln('13608'); halt; end;
if (375755757<n)and(n<=375755773) then begin writeln('13609'); halt; end;
if (375755773<n)and(n<=375755775) then begin writeln('13610'); halt; end;
if (375755775<n)and(n<=375755777) then begin writeln('13611'); halt; end;
if (375755777<n)and(n<=375757333) then begin writeln('13612'); halt; end;
if (375757333<n)and(n<=375757335) then begin writeln('13613'); halt; end;
if (375757335<n)and(n<=375757337) then begin writeln('13614'); halt; end;
if (375757337<n)and(n<=375757353) then begin writeln('13615'); halt; end;
if (375757353<n)and(n<=375757355) then begin writeln('13616'); halt; end;
if (375757355<n)and(n<=375757357) then begin writeln('13617'); halt; end;
if (375757357<n)and(n<=375757373) then begin writeln('13618'); halt; end;
if (375757373<n)and(n<=375757375) then begin writeln('13619'); halt; end;
if (375757375<n)and(n<=375757377) then begin writeln('13620'); halt; end;
if (375757377<n)and(n<=375757533) then begin writeln('13621'); halt; end;
if (375757533<n)and(n<=375757535) then begin writeln('13622'); halt; end;
if (375757535<n)and(n<=375757537) then begin writeln('13623'); halt; end;
if (375757537<n)and(n<=375757553) then begin writeln('13624'); halt; end;
if (375757553<n)and(n<=375757555) then begin writeln('13625'); halt; end;
if (375757555<n)and(n<=375757557) then begin writeln('13626'); halt; end;
if (375757557<n)and(n<=375757573) then begin writeln('13627'); halt; end;
if (375757573<n)and(n<=375757575) then begin writeln('13628'); halt; end;
if (375757575<n)and(n<=375757577) then begin writeln('13629'); halt; end;
if (375757577<n)and(n<=375757733) then begin writeln('13630'); halt; end;
if (375757733<n)and(n<=375757735) then begin writeln('13631'); halt; end;
if (375757735<n)and(n<=375757737) then begin writeln('13632'); halt; end;
if (375757737<n)and(n<=375757753) then begin writeln('13633'); halt; end;
if (375757753<n)and(n<=375757755) then begin writeln('13634'); halt; end;
if (375757755<n)and(n<=375757757) then begin writeln('13635'); halt; end;
if (375757757<n)and(n<=375757773) then begin writeln('13636'); halt; end;
if (375757773<n)and(n<=375757775) then begin writeln('13637'); halt; end;
if (375757775<n)and(n<=375757777) then begin writeln('13638'); halt; end;
if (375757777<n)and(n<=375773333) then begin writeln('13639'); halt; end;
if (375773333<n)and(n<=375773335) then begin writeln('13640'); halt; end;
if (375773335<n)and(n<=375773337) then begin writeln('13641'); halt; end;
if (375773337<n)and(n<=375773353) then begin writeln('13642'); halt; end;
if (375773353<n)and(n<=375773355) then begin writeln('13643'); halt; end;
if (375773355<n)and(n<=375773357) then begin writeln('13644'); halt; end;
if (375773357<n)and(n<=375773373) then begin writeln('13645'); halt; end;
if (375773373<n)and(n<=375773375) then begin writeln('13646'); halt; end;
if (375773375<n)and(n<=375773377) then begin writeln('13647'); halt; end;
if (375773377<n)and(n<=375773533) then begin writeln('13648'); halt; end;
if (375773533<n)and(n<=375773535) then begin writeln('13649'); halt; end;
if (375773535<n)and(n<=375773537) then begin writeln('13650'); halt; end;
if (375773537<n)and(n<=375773553) then begin writeln('13651'); halt; end;
if (375773553<n)and(n<=375773555) then begin writeln('13652'); halt; end;
if (375773555<n)and(n<=375773557) then begin writeln('13653'); halt; end;
if (375773557<n)and(n<=375773573) then begin writeln('13654'); halt; end;
if (375773573<n)and(n<=375773575) then begin writeln('13655'); halt; end;
if (375773575<n)and(n<=375773577) then begin writeln('13656'); halt; end;
if (375773577<n)and(n<=375773733) then begin writeln('13657'); halt; end;
if (375773733<n)and(n<=375773735) then begin writeln('13658'); halt; end;
if (375773735<n)and(n<=375773737) then begin writeln('13659'); halt; end;
if (375773737<n)and(n<=375773753) then begin writeln('13660'); halt; end;
if (375773753<n)and(n<=375773755) then begin writeln('13661'); halt; end;
if (375773755<n)and(n<=375773757) then begin writeln('13662'); halt; end;
if (375773757<n)and(n<=375773773) then begin writeln('13663'); halt; end;
if (375773773<n)and(n<=375773775) then begin writeln('13664'); halt; end;
if (375773775<n)and(n<=375773777) then begin writeln('13665'); halt; end;
if (375773777<n)and(n<=375775333) then begin writeln('13666'); halt; end;
if (375775333<n)and(n<=375775335) then begin writeln('13667'); halt; end;
if (375775335<n)and(n<=375775337) then begin writeln('13668'); halt; end;
if (375775337<n)and(n<=375775353) then begin writeln('13669'); halt; end;
if (375775353<n)and(n<=375775355) then begin writeln('13670'); halt; end;
if (375775355<n)and(n<=375775357) then begin writeln('13671'); halt; end;
if (375775357<n)and(n<=375775373) then begin writeln('13672'); halt; end;
if (375775373<n)and(n<=375775375) then begin writeln('13673'); halt; end;
if (375775375<n)and(n<=375775377) then begin writeln('13674'); halt; end;
if (375775377<n)and(n<=375775533) then begin writeln('13675'); halt; end;
if (375775533<n)and(n<=375775535) then begin writeln('13676'); halt; end;
if (375775535<n)and(n<=375775537) then begin writeln('13677'); halt; end;
if (375775537<n)and(n<=375775553) then begin writeln('13678'); halt; end;
if (375775553<n)and(n<=375775555) then begin writeln('13679'); halt; end;
if (375775555<n)and(n<=375775557) then begin writeln('13680'); halt; end;
if (375775557<n)and(n<=375775573) then begin writeln('13681'); halt; end;
if (375775573<n)and(n<=375775575) then begin writeln('13682'); halt; end;
if (375775575<n)and(n<=375775577) then begin writeln('13683'); halt; end;
if (375775577<n)and(n<=375775733) then begin writeln('13684'); halt; end;
if (375775733<n)and(n<=375775735) then begin writeln('13685'); halt; end;
if (375775735<n)and(n<=375775737) then begin writeln('13686'); halt; end;
if (375775737<n)and(n<=375775753) then begin writeln('13687'); halt; end;
if (375775753<n)and(n<=375775755) then begin writeln('13688'); halt; end;
if (375775755<n)and(n<=375775757) then begin writeln('13689'); halt; end;
if (375775757<n)and(n<=375775773) then begin writeln('13690'); halt; end;
if (375775773<n)and(n<=375775775) then begin writeln('13691'); halt; end;
if (375775775<n)and(n<=375775777) then begin writeln('13692'); halt; end;
if (375775777<n)and(n<=375777333) then begin writeln('13693'); halt; end;
if (375777333<n)and(n<=375777335) then begin writeln('13694'); halt; end;
if (375777335<n)and(n<=375777337) then begin writeln('13695'); halt; end;
if (375777337<n)and(n<=375777353) then begin writeln('13696'); halt; end;
if (375777353<n)and(n<=375777355) then begin writeln('13697'); halt; end;
if (375777355<n)and(n<=375777357) then begin writeln('13698'); halt; end;
if (375777357<n)and(n<=375777373) then begin writeln('13699'); halt; end;
if (375777373<n)and(n<=375777375) then begin writeln('13700'); halt; end;
if (375777375<n)and(n<=375777377) then begin writeln('13701'); halt; end;
if (375777377<n)and(n<=375777533) then begin writeln('13702'); halt; end;
if (375777533<n)and(n<=375777535) then begin writeln('13703'); halt; end;
if (375777535<n)and(n<=375777537) then begin writeln('13704'); halt; end;
if (375777537<n)and(n<=375777553) then begin writeln('13705'); halt; end;
if (375777553<n)and(n<=375777555) then begin writeln('13706'); halt; end;
if (375777555<n)and(n<=375777557) then begin writeln('13707'); halt; end;
if (375777557<n)and(n<=375777573) then begin writeln('13708'); halt; end;
if (375777573<n)and(n<=375777575) then begin writeln('13709'); halt; end;
if (375777575<n)and(n<=375777577) then begin writeln('13710'); halt; end;
if (375777577<n)and(n<=375777733) then begin writeln('13711'); halt; end;
if (375777733<n)and(n<=375777735) then begin writeln('13712'); halt; end;
if (375777735<n)and(n<=375777737) then begin writeln('13713'); halt; end;
if (375777737<n)and(n<=375777753) then begin writeln('13714'); halt; end;
if (375777753<n)and(n<=375777755) then begin writeln('13715'); halt; end;
if (375777755<n)and(n<=375777757) then begin writeln('13716'); halt; end;
if (375777757<n)and(n<=375777773) then begin writeln('13717'); halt; end;
if (375777773<n)and(n<=375777775) then begin writeln('13718'); halt; end;
if (375777775<n)and(n<=375777777) then begin writeln('13719'); halt; end;
if (375777777<n)and(n<=377333335) then begin writeln('13720'); halt; end;
if (377333335<n)and(n<=377333353) then begin writeln('13721'); halt; end;
if (377333353<n)and(n<=377333355) then begin writeln('13722'); halt; end;
if (377333355<n)and(n<=377333357) then begin writeln('13723'); halt; end;
if (377333357<n)and(n<=377333375) then begin writeln('13724'); halt; end;
if (377333375<n)and(n<=377333533) then begin writeln('13725'); halt; end;
if (377333533<n)and(n<=377333535) then begin writeln('13726'); halt; end;
if (377333535<n)and(n<=377333537) then begin writeln('13727'); halt; end;
if (377333537<n)and(n<=377333553) then begin writeln('13728'); halt; end;
if (377333553<n)and(n<=377333555) then begin writeln('13729'); halt; end;
if (377333555<n)and(n<=377333557) then begin writeln('13730'); halt; end;
if (377333557<n)and(n<=377333573) then begin writeln('13731'); halt; end;
if (377333573<n)and(n<=377333575) then begin writeln('13732'); halt; end;
if (377333575<n)and(n<=377333577) then begin writeln('13733'); halt; end;
if (377333577<n)and(n<=377333735) then begin writeln('13734'); halt; end;
if (377333735<n)and(n<=377333753) then begin writeln('13735'); halt; end;
if (377333753<n)and(n<=377333755) then begin writeln('13736'); halt; end;
if (377333755<n)and(n<=377333757) then begin writeln('13737'); halt; end;
if (377333757<n)and(n<=377333775) then begin writeln('13738'); halt; end;
if (377333775<n)and(n<=377335333) then begin writeln('13739'); halt; end;
if (377335333<n)and(n<=377335335) then begin writeln('13740'); halt; end;
if (377335335<n)and(n<=377335337) then begin writeln('13741'); halt; end;
if (377335337<n)and(n<=377335353) then begin writeln('13742'); halt; end;
if (377335353<n)and(n<=377335355) then begin writeln('13743'); halt; end;
if (377335355<n)and(n<=377335357) then begin writeln('13744'); halt; end;
if (377335357<n)and(n<=377335373) then begin writeln('13745'); halt; end;
if (377335373<n)and(n<=377335375) then begin writeln('13746'); halt; end;
if (377335375<n)and(n<=377335377) then begin writeln('13747'); halt; end;
if (377335377<n)and(n<=377335533) then begin writeln('13748'); halt; end;
if (377335533<n)and(n<=377335535) then begin writeln('13749'); halt; end;
if (377335535<n)and(n<=377335537) then begin writeln('13750'); halt; end;
if (377335537<n)and(n<=377335553) then begin writeln('13751'); halt; end;
if (377335553<n)and(n<=377335555) then begin writeln('13752'); halt; end;
if (377335555<n)and(n<=377335557) then begin writeln('13753'); halt; end;
if (377335557<n)and(n<=377335573) then begin writeln('13754'); halt; end;
if (377335573<n)and(n<=377335575) then begin writeln('13755'); halt; end;
if (377335575<n)and(n<=377335577) then begin writeln('13756'); halt; end;
if (377335577<n)and(n<=377335733) then begin writeln('13757'); halt; end;
if (377335733<n)and(n<=377335735) then begin writeln('13758'); halt; end;
if (377335735<n)and(n<=377335737) then begin writeln('13759'); halt; end;
if (377335737<n)and(n<=377335753) then begin writeln('13760'); halt; end;
if (377335753<n)and(n<=377335755) then begin writeln('13761'); halt; end;
if (377335755<n)and(n<=377335757) then begin writeln('13762'); halt; end;
if (377335757<n)and(n<=377335773) then begin writeln('13763'); halt; end;
if (377335773<n)and(n<=377335775) then begin writeln('13764'); halt; end;
if (377335775<n)and(n<=377335777) then begin writeln('13765'); halt; end;
if (377335777<n)and(n<=377337335) then begin writeln('13766'); halt; end;
if (377337335<n)and(n<=377337353) then begin writeln('13767'); halt; end;
if (377337353<n)and(n<=377337355) then begin writeln('13768'); halt; end;
if (377337355<n)and(n<=377337357) then begin writeln('13769'); halt; end;
if (377337357<n)and(n<=377337375) then begin writeln('13770'); halt; end;
if (377337375<n)and(n<=377337533) then begin writeln('13771'); halt; end;
if (377337533<n)and(n<=377337535) then begin writeln('13772'); halt; end;
if (377337535<n)and(n<=377337537) then begin writeln('13773'); halt; end;
if (377337537<n)and(n<=377337553) then begin writeln('13774'); halt; end;
if (377337553<n)and(n<=377337555) then begin writeln('13775'); halt; end;
if (377337555<n)and(n<=377337557) then begin writeln('13776'); halt; end;
if (377337557<n)and(n<=377337573) then begin writeln('13777'); halt; end;
if (377337573<n)and(n<=377337575) then begin writeln('13778'); halt; end;
if (377337575<n)and(n<=377337577) then begin writeln('13779'); halt; end;
if (377337577<n)and(n<=377337735) then begin writeln('13780'); halt; end;
if (377337735<n)and(n<=377337753) then begin writeln('13781'); halt; end;
if (377337753<n)and(n<=377337755) then begin writeln('13782'); halt; end;
if (377337755<n)and(n<=377337757) then begin writeln('13783'); halt; end;
if (377337757<n)and(n<=377337775) then begin writeln('13784'); halt; end;
if (377337775<n)and(n<=377353333) then begin writeln('13785'); halt; end;
if (377353333<n)and(n<=377353335) then begin writeln('13786'); halt; end;
if (377353335<n)and(n<=377353337) then begin writeln('13787'); halt; end;
if (377353337<n)and(n<=377353353) then begin writeln('13788'); halt; end;
if (377353353<n)and(n<=377353355) then begin writeln('13789'); halt; end;
if (377353355<n)and(n<=377353357) then begin writeln('13790'); halt; end;
if (377353357<n)and(n<=377353373) then begin writeln('13791'); halt; end;
if (377353373<n)and(n<=377353375) then begin writeln('13792'); halt; end;
if (377353375<n)and(n<=377353377) then begin writeln('13793'); halt; end;
if (377353377<n)and(n<=377353533) then begin writeln('13794'); halt; end;
if (377353533<n)and(n<=377353535) then begin writeln('13795'); halt; end;
if (377353535<n)and(n<=377353537) then begin writeln('13796'); halt; end;
if (377353537<n)and(n<=377353553) then begin writeln('13797'); halt; end;
if (377353553<n)and(n<=377353555) then begin writeln('13798'); halt; end;
if (377353555<n)and(n<=377353557) then begin writeln('13799'); halt; end;
if (377353557<n)and(n<=377353573) then begin writeln('13800'); halt; end;
if (377353573<n)and(n<=377353575) then begin writeln('13801'); halt; end;
if (377353575<n)and(n<=377353577) then begin writeln('13802'); halt; end;
if (377353577<n)and(n<=377353733) then begin writeln('13803'); halt; end;
if (377353733<n)and(n<=377353735) then begin writeln('13804'); halt; end;
if (377353735<n)and(n<=377353737) then begin writeln('13805'); halt; end;
if (377353737<n)and(n<=377353753) then begin writeln('13806'); halt; end;
if (377353753<n)and(n<=377353755) then begin writeln('13807'); halt; end;
if (377353755<n)and(n<=377353757) then begin writeln('13808'); halt; end;
if (377353757<n)and(n<=377353773) then begin writeln('13809'); halt; end;
if (377353773<n)and(n<=377353775) then begin writeln('13810'); halt; end;
if (377353775<n)and(n<=377353777) then begin writeln('13811'); halt; end;
if (377353777<n)and(n<=377355333) then begin writeln('13812'); halt; end;
if (377355333<n)and(n<=377355335) then begin writeln('13813'); halt; end;
if (377355335<n)and(n<=377355337) then begin writeln('13814'); halt; end;
if (377355337<n)and(n<=377355353) then begin writeln('13815'); halt; end;
if (777775733<n)and(n<=777775735) then begin writeln('26469'); halt; end;
if (777775735<n)and(n<=777775737) then begin writeln('26470'); halt; end;
if (777775737<n)and(n<=777775753) then begin writeln('26471'); halt; end;
if (777775753<n)and(n<=777775773) then begin writeln('26472'); halt; end;
if (777775773<n)and(n<=777777335) then begin writeln('26473'); halt; end;
if (777777335<n)and(n<=777777353) then begin writeln('26474'); halt; end;
if (777777353<n)and(n<=777777355) then begin writeln('26475'); halt; end;
if (777777355<n)and(n<=777777357) then begin writeln('26476'); halt; end;
if (777777357<n)and(n<=777777375) then begin writeln('26477'); halt; end;
if (777777375<n)and(n<=777777533) then begin writeln('26478'); halt; end;
if (777777533<n)and(n<=777777535) then begin writeln('26479'); halt; end;
if (777777535<n)and(n<=777777537) then begin writeln('26480'); halt; end;
if (777777537<n)and(n<=777777553) then begin writeln('26481'); halt; end;
if (777777553<n)and(n<=777777573) then begin writeln('26482'); halt; end;
if (777777573<n)and(n<=777777735) then begin writeln('26483'); halt; end;
if (777777735<n)and(n<=777777753) then begin writeln('26484'); halt; end;
  for i:=m to n do
  begin
    b1:=false;
    b2:=false;
    b3:=false;
    s:='';
	str(i,s);
    s:=s+'4';
    for j:=1 to length(s) do 
    begin 
      if (s[j]<>'3')and(s[j]<>'5')and(s[j]<>'7') then break;
      if s[j]='3' then b1:=true;
      if s[j]='5' then b2:=true;
      if s[j]='7' then b3:=true;
    end;
    if b1 and b2 and b3 and(j=length(s)) then inc(ans);
  end;
  writeln(ans);
end.