#include <bits/stdc++.h>
using namespace std;
class A {
 public:
  void solve(istream& in, ostream& out) {
    string s, rev;
    in >> s;
    rev = s;
    reverse(rev.begin(), rev.end());
    int res = 0;
    while (s != rev) {
      ++res;
      int mm = (s[3] - '0') * 10 + (s[4] - '0');
      int hh = (s[0] - '0') * 10 + (s[1] - '0');
      ++mm;
      if (mm > 59) {
        mm -= 60;
        ++hh;
      }
      if (hh > 23) {
        hh -= 24;
      }
      s = (hh < 10 ? "0" : "") + to_string(hh) + ":" + (mm < 10 ? "0" : "") +
          to_string(mm);
      rev = s;
      reverse(rev.begin(), rev.end());
    }
    out << res << "\n";
  }
};
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  A solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
