#include <bits/stdc++.h>
using namespace std;
class Problem {
 public:
  virtual void main() = 0;
};
class Problem_A : public Problem {
  string s;
  void main() override {
    while (cin >> s) {
      cout << solve() << endl;
    }
  }
  int solve() {
    string tmp = s;
    int ans = 0;
    while (!is_pal(tmp)) {
      ans++;
      tmp = next_time(tmp);
    }
    return ans;
  }
  string next_time(string tmp) {
    string hh = tmp.substr(0, 2);
    string mm = tmp.substr(3, 2);
    int mmi = stoi(mm);
    int hhi = stoi(hh);
    mmi++;
    if (mmi == 60) {
      mmi = 0;
      hhi++;
    }
    if (hhi == 24) {
      hhi = 0;
    }
    if (mmi < 10) {
      mm = "0";
      mm += to_string(mmi);
    } else {
      mm = to_string(mmi);
    }
    if (hhi < 10) {
      hh = "0";
      hh += to_string(hhi);
    } else {
      hh = to_string(hhi);
    }
    return hh + ":" + mm;
  }
  bool is_pal(string s) {
    for (int i = 0; i < s.size() / 2; i++)
      if (s[i] != s[s.size() - i - 1]) return 0;
    return 1;
  }
};
int main() {
  unique_ptr<Problem> problem(new Problem_A());
  problem->main();
  return 0;
}
