import java.util.Scanner;
public class Main{
public static void main (String[] args){
try (Scanner in = new Scanner(System.in)) {
int x = in.nextInt();
int a,b,c;
long y,d;
if( x >= 100 && x <1000) {
a = x / 100;
b = x / 10 % 10;
c = x % 10;
y = a * 100000 + b * 10000 + c * 1000 + x;
d = y / 7 / 11 / 13;
System.out.println(d);
}
}
}
}
/**************************************************************
Problem: 1961
User: admin
Language: Java
Result: Accepted
Time:787 ms
Memory:40140 kb
****************************************************************/