#include<iostream>
#include<cmath>
#include<string>
using namespace std;

class TechNumberChecker
{
    public:
    virtual int isTechNumber() = 0;
    virtual ~TechNumber() {}
};
class IntTech : public TechNumberChecker
{
    long long num;
    public:
    IntTech(long long n) {num = n;}
    int isTechNumber()
    {
        string s=to_string(num);
        if(s.length() % 2!=0)
        return 0;
        int mid=s.length() /2;
        
        long long first =stoll(s.substr(0,mid));
        long long second=stoll(s.substr(mid));\
        long long sum=first+second;
        if(sum*sum == num)
        return 1;
        return 0;
    }
};
class FloatTech : public TechNumberChecker
{
    double num;
    public:
    FloatTech(double n) { num = n;}
    int isTechNumber()
    {
        long long intPart=(long long)num;
        string s=to_string(intPart);
        if(s.length() % 2 !=0)
        return 0;
        int mid =s.length() /2;
        long long first =stoll(s.substr(0,mid));
        long long second=stoll(s.substr(mid));
        long long sum=first+second;
        if(sum*sum==intPart)
        return 1;
        return 0;
    }
};
int main()
{
    int keyType;
    cin>>keyType;
    if(keyType !=1 && keyType !=2)
    {
        cout<< -1;
        return 0;
    }
    TechNumberChecker *obj = Null;
    if(keyType ==1)
    {
        long long n;
        if(!(cin >> n))
        {
            cout<< "Invalid input";
            return 0;
        }
        obj = new IntTech(n);
    }
    else if(keyType == 2)
    {
        double f;
        if(!(cin>>f))
        {
            cout<<"Invalid input";
            return 0;
        }
        obj = new FloatTech(f);
    }
    cout<<obj->isTechNumber();
    delete obj;
    return 0;
}