import java.io.*;
import java.util.*;
import java.net.*;
import java.math.*;
//_____________________________________________________________
public class pattern85
{ 
   String[] allargs = "BRAJYO BRA ALHYM AO HJMYM VAO HARE".split(" ");
   int va = 3;
   int vb = 7;
   int ve = 777;
   String sa = "3";
   String sb = "7";
   String se = "777";
   String sc = Integer.toString(va) + Integer.toString(vb);
   String sd = Integer.toString(vb) + Integer.toString(va);
   int vc = Integer.parseInt(sc);
   int vd = Integer.parseInt(sd);
   static String out = "";
   boolean v37 = true;

//_____________________________________________________________
public static final void main(String[] args) throws Exception
{
   pattern85 bnk = new pattern85();
   System.out.println(bnk.start());
}
//_____________________________________________________________
pattern85() throws Exception 
{
}
//___________________________________________________________________________
int start()
{
   if (!v37)
   {
      va = 2;
      vb = 5;
      ve = 555;
      sa = "2";
      sb = "5";
      se = "555";
      sc = "25";
      sd = "52";
      vc = 25;
      vd = 52;
   }


   int cnt = 0;
   StringBuffer buf = new StringBuffer();
   for (int i = 0; i < allargs.length; i++)
   {
      buf.append(value(allargs[i]));
   }
   BigInteger bga = new BigInteger(buf.toString());
   BigInteger bgb = new BigInteger("718642971");
   BigInteger bgc = bga.divide(bgb);
   BigInteger bgd = bga.mod(bgb);
   String sgc = bgc.toString();
   String sgd = bgd.toString();
   boolean ok = true;
   //if (sgc.indexOf("73373") < 0) ok = false;
   if (sgc.indexOf(sd + sc + sa) < 0) ok = false;
   //if (!digits(sgc).equals("37")) ok = false;
   if (!digits(sgc).equals(sc)) ok = false;
   //if (!digits(sgd).equals("37")) ok = false;
   if (!digits(sgd).equals(sc)) ok = false;
   if (ok) cnt++;
   BigInteger bge = new BigInteger("519937098"); 
   BigInteger bgf = bga.divide(bge);
   String sgf = bgf.toString();
   if (sgf.length() < 9) return(85);
   //if (sgf.substring(sgf.length() - 8).equals("37373737")) cnt++;
   if (sgf.substring(sgf.length() - 8).equals(sc + sc + sc + sc)) cnt++;
   BigInteger bgg = new BigInteger("40275842"); 
   BigInteger bgh = bga.divide(bgg);
   String sgh = bgh.toString();
   if (sgh.length() < 9) return(85);
   //if (sgh.substring(sgh.length() - 10).equals("7373737373")) cnt++;
   if (sgh.substring(sgh.length() - 10).equals(sd + sd + sd + sd + sd)) cnt++;
   BigInteger bgg2 = new BigInteger("273599679"); 
   BigInteger bgh2 = bga.divide(bgg2);
   String sgh2 = bgh2.toString();
   if (sgh2.length() < 9) return(85);
   //if (sgh2.substring(sgh2.length() - 10).equals("3337737337")) cnt++;
   if (sgh2.substring(0,10).equals(sa + sa + sc + sd + sd + sc)) cnt++;
   if (cnt >= 4) 
   {
      //aregood[85]++;
      return(-1);
   }
   return(85);
}
//___________________________________________________________________________
String digits(String str)
{
   int total = 0;
   for (int i = 0; i < str.length(); i++)
   {
      String s = str.substring(i,i+1);
      int v = Integer.parseInt(s);
      total += v;
   }
   return(Integer.toString(total));
}
//__________________________________________________
public static 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);
}

//__________________________________________________
public static 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);
}

}//__________________________________________________________________________
