#include <bits/stdc++.h>
using namespace std;
int p[2000005];
int cntp = 0;
void criba() {
  for (int i = 4; i < 2000005; i += 2) p[i] = 2;
  for (int i = 3; i * i < 2000005; i += 2)
    if (!p[i])
      for (int j = i * i; j < 2000005; j += 2 * i) p[j] = i;
  for (int i = 2; i < 2000005; i++)
    if (!p[i]) {
      p[i] = 1;
      cntp++;
    } else
      p[i] = 0;
  p[1] = 0;
  for (int i = 2; i < 2000005; i++) {
    p[i] += p[i - 1];
  }
}
int B[2 * 2000005];
void cap() {
  for (int i = 1; i <= 9; i++) {
    B[i] = 1;
  }
  for (int i = 1; i <= 9; i++) B[11 * i] = 1;
  for (int i = 1; i <= 9; i++)
    for (int j = 0; j <= 9; j++) B[101 * i + 10 * j] = 1;
  for (int i = 1; i <= 9; i++)
    for (int j = 0; j <= 9; j++) B[1001 * i + 110 * j] = 1;
  for (int a = 1; a <= 9; a++)
    for (int b = 0; b <= 9; b++)
      for (int c = 0; c <= 9; c++) B[10001 * a + 1010 * b + 100 * c] = 1;
  for (int a = 1; a <= 9; a++)
    for (int b = 0; b <= 9; b++)
      for (int c = 0; c <= 9; c++) B[100001 * a + 10010 * b + 1100 * c] = 1;
  for (int a = 1; a <= 2; a++)
    for (int b = 0; b <= 9; b++)
      for (int c = 0; c <= 9; c++)
        for (int d = 0; d <= 9; d++)
          B[1000001 * a + 100010 * b + 10100 * c + 1000 * d] = 1;
  for (int i = 1; i < 2000005; i++) {
    B[i] += B[i - 1];
  }
}
int main() {
  criba();
  cap();
  long long a, b;
  cin >> a >> b;
  for (int i = 2000000; i >= 1; i--) {
    if (b * p[i] <= a * B[i]) {
      cout << i << endl;
      break;
    }
  }
}
