#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  cin >> x;
  while (1) {
    if (x[4] == '9') {
      x[4] = '0';
      if (x[3] == '5') {
        x[3] = '0';
        if (x[1] == '9') {
          x[1] = '0';
          if (x[0] == '1')
            x[0] = '2';
          else if (x[0] == '0')
            x[0] = '1';
        } else if (x[1] == '3' && x[0] == '2')
          x[1] = x[0] = '0';
        else
          x[1]++;
      } else
        x[3]++;
    } else
      x[4]++;
    string t = x;
    reverse(t.begin(), t.begin() + t.size());
    if (t == x) {
      cout << x << endl;
      return 0;
    }
  }
}
