// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int main() {
  string s; in(s);
  int n = s.size();
  loop(len,2,4) {
    if (len > n) break;
    loop(l,0,n-len+1) {
      map<char, int> M;
      int max_ = 0;
      loop(i,l,l+len) {
        M[s[i]]++;
        max_ = max(max_, M[s[i]]);
      }
      if (max_ > len/2) {
        cout << l+1 << " " << l+len << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1" << endl;
  return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll pow[19];

ll dfs(int k, int i, ll dif, ll dif_org){
    // if(k == 4) cout << dif << endl;
    if(i < k-i+1) return dif == 0 ? 1:0;
    if(i == k-i+1){
        if(dif == 0){
            if(k != i){
                return 10;
            }else{
                return 9;
            }
        }else{
            return 0;
        }
    }
    ll d = pow[i-1]-pow[k-i];
    ll r = dif%d;
    ll m = dif/d;
    ll sum = 0;
    if(r == 0){
        if(abs(m) < 10) {
            if(k != i){
                sum += (10-abs(m))*dfs(k, i-1, r, dif_org);
            }else{
                sum += (10-abs(m)-1)*dfs(k, i-1, r, dif_org);
            }
        }
    }else{
        if(abs(m) < 10) {
            if(k != i){
                sum += (10-abs(m))*dfs(k, i-1, r, dif_org);
            }else{
                sum += (10-abs(m)-1)*dfs(k, i-1, r, dif_org);
            }
        }
        if(dif > 0){
            if(abs(m)+1 < 10) {
                if(k != i){
                    sum += (10-abs(m)-1)*dfs(k, i-1, r-d, dif_org);
                }else{
                    sum += (10-abs(m)-2)*dfs(k, i-1, r-d, dif_org);
                }
            }
        }else if(dif < 0){
            if(abs(m)+1 < 10) {
                if(k != i){
                    sum += (10-abs(m)-1)*dfs(k, i-1, r+d, dif_org);
                }else{
                    sum += (10-abs(m)-2)*dfs(k, i-1, r+d, dif_org);
                }
            }
        }
    }
    return sum;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    pow[0] = 1;
    for(int i = 1; i < 19; i++) pow[i] = pow[i-1]*10; 
    ll D;
    cin >> D;
    ll ans = 0;
    for(int i = 1; i <= 19; i++){
        ans += dfs(i, i, D, D);
        // cout << i << ' ' << ans << endl;
    }
    cout << ans << endl;
}