#include <bits/stdc++.h>
using namespace std;
void ff() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
void in_out_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
bool palindrome(string str) {
  string s;
  s = str;
  reverse(s.begin(), s.end());
  if (str.compare(s) == 0) return true;
  return false;
}
int main() {
  ff();
  string str, s1, s2;
  int num1, num2;
  cin >> str;
  int co = 0;
  while (!palindrome(str)) {
    s1 = str.substr(0, 2);
    s2 = str.substr(3, 2);
    num1 = stoi(s1), num2 = stoi(s2);
    num2++;
    if (num2 == 60) {
      num2 = 0;
      num1++;
      if (num1 == 24) num1 = 0;
    }
    s1 = to_string(num1);
    if (s1.size() == 1) s1 = '0' + s1;
    s2 = to_string(num2);
    if (s2.size() == 1) s2 = '0' + s2;
    str = s1 + ':' + s2;
    co++;
  }
  cout << co << endl;
  return 0;
}
