#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int h1, m1, h2, m2;
  set<string> s = {"00:00", "01:10", "02:20", "03:30", "04:40", "05:50",
                   "10:01", "11:11", "12:21", "13:31", "14:41", "15:51",
                   "20:02", "21:12", "22:22", "23:32", "24:00"};
  cin >> s1;
  h1 = stoi(s1.substr(0, 2));
  m1 = stoi(s1.substr(3, 2));
  s2 = *s.lower_bound(s1);
  h2 = stoi(s2.substr(0, 2));
  m2 = stoi(s2.substr(3, 2));
  cout << (h2 * 60 + m2) - (h1 * 60 + m1);
}
