#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NUM		600851475143

void sieve(int *table, int square);

int main(void)	{
  int *table, square;
  long long i;

  square = sqrt((double ) NUM);
  table = (int *) malloc( ( square + 1 ) * sizeof(int));

  for(i = 0; i <= square; i++)
    table[i] = 1;

  sieve(table, square);

  for(i = square; i >= 2; i--)	{
    if( !(NUM % i) && table[i] == 1)	{
      printf("%lld\n", i);
      return 0;
    }
  }

  printf("\n");
  return 0;
}

void sieve(int *table, int square)
{
  int i, j;

  table[0] = table[1] = 0;

  for(i = 2; i <= square; i++)	{
    for(j = 2 * i; j <= square; j += i)
      table[j] = 0;
  }
}