#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    string str;
    cin >> str;
    int n = (str[0] - '0') * 10 + str[1] - '0';
    int m = (str[3] - '0') * 10 + str[4] - '0';
    int ans = 0;
    while (1) {
      if (n % 10 == m / 10 && n / 10 == m % 10) break;
      m++;
      if (m >= 60) n++;
      n = n % 24;
      m = m % 60;
      ans++;
    }
    cout << ans << endl;
  }
}
