#include <iostream>
#include <string>
#include <cmath>
using namespace std;

class TechNumberChecker {
    public:
    virtual bool isTechNumber(int n) {
        return false;
    }
    
    virtual bool isTechNumber(float f) {
        return false;
    }
    
    virtual ~TechNumberChecker() {}
};

class IntTechChecker : public TechNumberChecker {
    public:
    bool isTechNumber (int n) override {
        string s = to_string(n);
        if (s.length() % 2 != 0) return false;
        
        int mid = s.length() / 2;
        int left = stoi(s.substr(0, mid));
        int right = stoi(s.substr(mid));
        
        return (left + right) * (left + right) == n;
    }
};

class FloatTechChecker : public TechNumberChecker {
    public:
    bool isTechNumber (float f) override {
        int n = (int)f;
        strings = to_string(n);
        if (s.length() % 2 != 0) return false;
        
        int mid = s.length() / 2;
        int left = stoi(s.substr(0, mid));
        int right = stoi(s.substr(mid));
        
        return (left + right) * (left + right) == n;
    }
};

bool isValidInt(const string& s) {
    if (s.empty()) return false;
    for (char c : s) {
        if (!isdigit(c)) return false;
    }
    return true;
}

bool isValidFloat(const string& s) {
    if (s.empty()) return false;
    int dotCount = 0;
    for (char c : s) {
        if (c == '.') dotCount++;
        else if (!isdigit(c)) return false;
    }
    return dotCount <= 1;
}

int main() {
    int keyType;
    cin >> keyType;
    string input;
    cin >> input;
    
    if (keyType == 1) {
        if (!isValidInt(input)) {
            cout << "Invalid input" << endl;
        } else {
            int num = stoi(input);
            IntTechChecker checker;
            cout << (checker.isTechNumber(num) ? 1 : 0) << endl;
        }
    } else if (keyType == 2) {
        if (!isValidFloat(input)) {
            cout << "Invalid input" << endl;
        } else {
            float num = stof(input);
            FloatTechChecker checker;
            cout << (checker.isTechNumber(num) ? 1 : 0) << endl;
        }
    } else {
        cout << -1 << endl;
    }
}