import java.io.*;
import java.util.*;
import java.net.*;
//_____________________________________________________________
public class letters
{ 
   String gen11  = "BRAJYO BRA ALHYM AO HJMYM VAO HARE";
   byte[] bb = data.getBytes("pi.dec");
//_____________________________________________________________
public static final void main(String[] args) throws Exception
{
   long t1 = System.nanoTime();
   letters bnk = new letters();
   bnk.start2();
   bnk.start(args);
   long t2 = System.nanoTime();
   System.out.println("seconds = " + ((t2-t1)/1e9));
}
//_____________________________________________________________
letters() throws Exception 
{
}
//___________________________________________________________________________
void start2()
{
   String[] words = gen11.split(" ");
   for (int i = 0; i < words.length; i++)
   {
       System.out.println(data.place(words[i]) + " \t" + data.value(words[i]));
   }
}
//___________________________________________________________________________
void start(String[] args)
{
   
   String pi = "3141592653589793";
   String look = "31415926";
   if (args.length > 0) look = args[0];
   String gen = gen11.replace(" ","");
   System.out.println(data.value(gen));
   for (int i = 0; i < 100000000; i++)
   {
      int total3 = 0;
      StringBuffer buf3 = new StringBuffer();
      for (int j = 0; j < gen.length(); j++)
      {
         String s = gen.substring(j,j+1);
         int val = data.value(s);
         int pla = data.place(s);
         total3 += pla;
         if (total3+1 >= bb.length) continue;
         buf3.append((char)bb[total3+i]);
      }
      boolean ok = false;
      if (buf3.toString().substring(0,look.length()).equals(look)) ok = true;
      if (ok)
      {
         System.out.println(i);
         System.out.println(reverse(Integer.toString(i)));
         System.out.println(buf3.toString()); // + " " + digits(buf3.toString()));
         break; // comment out this line to look at first 100,000,000 digits of 'pi'
      }
   }
}
//___________________________________________________________________________
String reverse(String str)
{
   String out = "";
   for (int i = str.length() - 1; i >= 0; i--)
   {
      String s = str.substring(i,i+1);
      out += s;
   }
   return(out);
}
}//__________________________________________________________________________
