#include <stdio.h>
int count = 0;
int main()
{
    int x = 0;
    scanf("%d", &x);
    for (int i = 0; i <= x; i++)
    {
        
        int j = i;
        int y = i * i;
        while (j % 10 == y % 10)
        {
            j = j / 10;
            y = y / 10;
            if (j == 0)
            {
                count++;
                break;
            }
        }

    }
    printf("%d", count);
    return 0;
}