#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include  <cstdlib>
#include <string.h> 
#include <cstring>
#include <queue>
#include <map>

using namespace std;

#pragma warning(disable:4996)
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define EPS 1e-11
#define PI acos(-1.0)

typedef unsigned long long ll;

ll arr[20010], arr1[20010];
vector<ll>v;
ll a, b;
map<unsigned long long, unsigned int> m;
priority_queue < ll, vector<ll>, greater<ll> > pq;

int main() 
{
    int x;
    cin >> x;
    if (x >= 0) cout << x;
    else cout << 0;
}

#include <iostream>
#include <vector>
using namespace std;


int main() {
	
	long long  n;
	cin >> n;
	vector<int> digs;
	while (n) {
		digs.push_back(n % 10);
		n /= 10;
	}
	vector<int> rec(3);
	int s = 0;
	for (auto x : digs) rec[x % 3] ++, s += x;
	s %= 3;
	if (s == 0) cout << 0;
	else if (s == 1) {
		if (rec[1] > 0 && digs.size() > 1) cout << 1;
		else if (rec[2] > 1 && digs.size() > 2) cout << 2;
		else cout << -1;
	} else {
		if (rec[2] > 0 && digs.size() > 1) cout << 1;
		else if (rec[1] > 1 && digs.size() > 2) cout << 2;
		else cout << -1;
	}
	return 0;
	
}