import java.io.*;
import java.util.*;
import java.net.*;
import java.math.*;
//_____________________________________________________________
public class pos
{ 
   String gen11  = "BRAJYO BRA ALHYM AO HJMYM VAO HARE";
   String pi = getFile2("pi.dec");
   String nums = "2910512911635711307574113198";
   static boolean show = false;
   String out = "";
//_____________________________________________________________
public static final void main(String[] args) throws Exception
{
   show = true;
   pos bnk = new pos();
   bnk.start(args);
}
//_____________________________________________________________
pos() throws Exception 
{
}
//___________________________________________________________________________
boolean start(String[] argsv)
{
   int[] lk = new int[30];
   int[] lk2 = new int[30];
   int lk2pos = 0;
   if (argsv.length == 0) argsv = gen11.split(" ");
   gen11 = "";
   for (int i = 0; i < argsv.length; i++)
   {
      gen11 += argsv[i];
   }
   for (int i = 0; i < gen11.length(); i++)
   {
      String s = gen11.substring(i,i+1);
      int pla = place(s);
      lk[pla]++;
   }
   for (int i = 0; i < lk.length; i++)
   {
      if (lk[i] > 0)
      {
         lk2pos++;
         lk2pos = lk2pos % 10;
         lk2[i] = lk2pos;
      }
   }
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < gen11.length(); i++)
   {
      String s = gen11.substring(i,i+1);
      int pla = place(s);
      buf.append(Integer.toString(lk2[pla]));
   }
   return(tryit(gen11,buf.toString()));
}
//___________________________________________________________________________
boolean tryit(String gen11,String nums)
{

//System.out.println(gen11 + " " + nums);

   int pla = place(gen11);
   int val = value(gen11);
   int num = val * pla;
   BigInteger bga = new BigInteger(nums);
   BigInteger bgb = new BigInteger(Integer.toString(num));
   BigInteger bgc = bga.divide(bgb);
   String st = bgc.toString();
   return(startit(-1,st));
}
//___________________________________________________________________________
boolean startit(int pss, String num2)
{
   StringBuffer buf = new StringBuffer();
   int count = 0;
   for (int i = 1; i < num2.length(); i++)
   {
      String s = num2.substring(0,i);
      int ps = pi.indexOf(s);
      if (ps < 0) break;
      String psstr = Integer.toString(ps);
      boolean ok = false;
      if (psstr.indexOf("7337") >= 0) ok = true;
      if (psstr.indexOf("3773") >= 0) ok = true;
      if (psstr.indexOf("5225") >= 0) ok = true;
      if (psstr.indexOf("2552") >= 0) ok = true;
      if (ok)
      {
         count++;
         buf.append("\r\n" + pss + " " + i + " " + num2 + " " + ps + " " + gen11);
         if (count > 1)
         {
            if (show) System.out.print(buf.toString());
            data.saveFile("pos.txt",buf.toString(),true);
         }
      }
      else count = 0;
          
   }
   if (count > 1) return(true);
   return(false);
}
//___________________________________________________________________________
String getFile2(String file) 
{
   StringBuffer buf=new StringBuffer();String str;
  try
  {
   BufferedReader in = new BufferedReader (new FileReader (file));
   while((str=in.readLine())!=null)
   {
      buf.append(str);
   }
   in.close();
  }
  catch (Exception e)
  {
   System.out.println(e);
  }
   return (buf.toString());
}
//__________________________________________________
int value(String str)
{
   int total = 0;
   out = "";
   for (int i = 0; i < str.length(); i++)
   {
      int v = 0;
      String st2 = str.substring(i,i+1);
      byte[] st3 = st2.getBytes();
      byte st = st3[0];
      if (st == 'a') v = 1;
      else if (st == 'b') v = 2;
      else if (st == 'c') v = 3;
      else if (st == 'd') v = 4;
      else if (st == 'e') v = 5;
      else if (st == 'f') v = 6;
      else if (st == 'g') v = 7;
      else if (st == 'h') v = 8;
      else if (st == 'i') v = 9;
      else if (st == 'j') v = 10;
      else if (st == 'k') v = 20;
      else if (st == 'l') v = 30;    
      else if (st == 'm') v = 40;
      else if (st == 'n') v = 50;
      else if (st == 'o') v = 60;
      else if (st == 'p') v = 70;
      else if (st == 'q') v = 80;
      else if (st == 'r') v = 90;
      else if (st == 's') v = 100;
      else if (st == 't') v = 200;
      else if (st == 'u') v = 300;
      else if (st == 'v') v = 400;
      else if (st == 'w') v = 500;
      else if (st == 'x') v = 600;
      else if (st == 'y') v = 700;
      else if (st == 'z') v = 800;
      else if (st == 'A') v = 1;
      else if (st == 'B') v = 2;
      else if (st == 'G') v = 3;
      else if (st == 'D') v = 4;
      else if (st == 'H') v = 5;
      else if (st == 'V') v = 6;
      else if (st == 'Z') v = 7;
      else if (st == 'C') v = 8;
      else if (st == 'T') v = 9;
      else if (st == 'Y') v = 10;
      else if (st == 'K') v = 20;
      else if (st == 'L') v = 30;
      else if (st == 'M') v = 40;
      else if (st == 'N') v = 50;
      else if (st == 'S') v = 60;
      else if (st == 'I') v = 70;
      else if (st == 'F') v = 80;
      else if (st == 'E') v = 90;
      else if (st == 'Q') v = 100;
      else if (st == 'R') v = 200;
      else if (st == 'J') v = 300;
      else if (st == 'O') v = 400;
      total += v;
      if (i > 0) out += " + ";
      out += Integer.toString(v);
   }
   return(total);
}
//__________________________________________________
int place(String str)
{
   int total = 0;
   out = "";
   for (int i = 0; i < str.length(); i++)
   {
      int v = 0;
      String st2 = str.substring(i,i+1);
      byte[] st3 = st2.getBytes();
      byte st = st3[0];
      if (st == 'a') v = 1;
      else if (st == 'b') v = 2;
      else if (st == 'c') v = 3;
      else if (st == 'd') v = 4;
      else if (st == 'e') v = 5;
      else if (st == 'f') v = 6;
      else if (st == 'g') v = 7;
      else if (st == 'h') v = 8;
      else if (st == 'i') v = 9;
      else if (st == 'j') v = 10;
      else if (st == 'k') v = 11;
      else if (st == 'l') v = 12;    
      else if (st == 'm') v = 13;
      else if (st == 'n') v = 14;
      else if (st == 'o') v = 15;
      else if (st == 'p') v = 16;
      else if (st == 'q') v = 17;
      else if (st == 'r') v = 18;
      else if (st == 's') v = 19;
      else if (st == 't') v = 20;
      else if (st == 'u') v = 21;
      else if (st == 'v') v = 22;
      else if (st == 'w') v = 23;
      else if (st == 'x') v = 24;
      else if (st == 'y') v = 25;
      else if (st == 'z') v = 26;
      else if (st == 'A') v = 1;
      else if (st == 'B') v = 2;
      else if (st == 'G') v = 3;
      else if (st == 'D') v = 4;
      else if (st == 'H') v = 5;
      else if (st == 'V') v = 6;
      else if (st == 'Z') v = 7;
      else if (st == 'C') v = 8;
      else if (st == 'T') v = 9;
      else if (st == 'Y') v = 10;
      else if (st == 'K') v = 11;
      else if (st == 'L') v = 12;
      else if (st == 'M') v = 13;
      else if (st == 'N') v = 14;
      else if (st == 'S') v = 15;
      else if (st == 'I') v = 16;
      else if (st == 'F') v = 17;
      else if (st == 'E') v = 18;
      else if (st == 'Q') v = 19;
      else if (st == 'R') v = 20;
      else if (st == 'J') v = 21;
      else if (st == 'O') v = 22;
      total += v;
      if (i > 0) out += " + ";
      out += Integer.toString(v);
   }
   return(total);
}
}//__________________________________________________________________________
